{"id":13602653,"url":"https://github.com/bash-my-aws/bash-my-aws","last_synced_at":"2025-04-11T09:30:46.317Z","repository":{"id":25511179,"uuid":"28942758","full_name":"bash-my-aws/bash-my-aws","owner":"bash-my-aws","description":"Bash-my-AWS provides simple but powerful CLI commands for managing AWS resources","archived":false,"fork":false,"pushed_at":"2025-04-09T04:34:07.000Z","size":6447,"stargazers_count":970,"open_issues_count":25,"forks_count":230,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-09T05:26:55.650Z","etag":null,"topics":["aws","aws-cli","awscli","bash","cli","pipe","pipe-skimming","shell"],"latest_commit_sha":null,"homepage":"https://bash-my-aws.org/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bash-my-aws.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-08T01:28:14.000Z","updated_at":"2025-04-09T04:34:10.000Z","dependencies_parsed_at":"2023-10-16T14:20:30.661Z","dependency_job_id":"76b747b2-c8ca-4384-94f3-f362327cd683","html_url":"https://github.com/bash-my-aws/bash-my-aws","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bash-my-aws%2Fbash-my-aws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bash-my-aws%2Fbash-my-aws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bash-my-aws%2Fbash-my-aws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bash-my-aws%2Fbash-my-aws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bash-my-aws","download_url":"https://codeload.github.com/bash-my-aws/bash-my-aws/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248368185,"owners_count":21092314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-cli","awscli","bash","cli","pipe","pipe-skimming","shell"],"created_at":"2024-08-01T18:01:32.874Z","updated_at":"2025-04-11T09:30:45.512Z","avatar_url":"https://github.com/bash-my-aws.png","language":"Shell","readme":"# Bash-my-AWS\n\nBash-my-AWS is a simple but powerful set of CLI commands for managing\nresources on Amazon Web Services.\n\nThey harness the power of Amazon's AWSCLI, while abstracting away verbosity.\n\nThe project implements some innovative patterns but (arguably) remains simple,\nbeautiful and readable.\n\n**Note: Extensive documentation at \u003chttps://bash-my-aws.org/\u003e**\n\n![screencast](docs/images/bma-02-2.gif)\n\n## Introduction\n\n- [Bash-my-AWS](#bash-my-aws)\n  - [Introduction](#introduction)\n    - [Short, Memorable Commands](#short-memorable-commands)\n    - [Shell Command Completion](#shell-command-completion)\n    - [Unix Pipeline Friendly](#unix-pipeline-friendly)\n    - [Convenient Shortcuts](#convenient-shortcuts)\n  - [Quickstart](#quickstart)\n    - [Prerequisites](#prerequisites)\n    - [Optional Packages](#optional-packages)\n    - [Installation](#installation)\n      - [Why use shell aliases?](#why-use-shell-aliases)\n  - [Usage](#usage)\n    - [Running Commands](#running-commands)\n    - [Discovering Commands](#discovering-commands)\n    - [Piping Between Commands](#piping-between-commands)\n    - [Inspecting Commands](#inspecting-commands)\n\n### Short, Memorable Commands\n\nThere are two main types of commands.\n\n**1. Resource Listing Commands**\n\nThese generally consist of the pluralised form of the resource name.\n\n```shell\n$ buckets\nexample-assets   2019-12-08  02:35:44.758551\nexample-logs     2019-12-08  02:35:52.669771\nexample-backups  2019-12-08  02:35:56.579434\n```\n\n```shell\n$ stacks\nnagios      CREATE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\npostgres01  CREATE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\npostgres02  CREATE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\nprometheus  CREATE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\n```\n\n```shell\n$ keypairs\nalice  8f:85:9a:1e:6c:76:29:34:37:45:de:7f:8d:f9:70:eb\nbob    56:73:29:c2:ad:7b:6f:b6:f2:f3:b4:de:e4:2b:12:d4\ncarol  29:4e:1c:cb:ba:d4:85:0e:4f:b6:34:4c:d4:79:32:00\n```\n\n**2. Resource detail/action commands**\n\nThese generally consist of a resource name and action separated by a hyphen.\nThis makes discovering them via shell completion simple.\n\nSome retrieve information about resources while others make changes to them.\n\n```shell\n$ keypair-delete alice bob\nYou are about to delete the following EC2 SSH KeyPairs:\nalice\nbob\nAre you sure you want to continue? y\n```\n\nSee the [Command Reference](https://bash-my-aws.org/command-reference/) for a full list of commands.\n\n### Shell Command Completion\n\nIn the example above, shell autocompletion retrieved the existing EC2 Keypair\nnames (`alice`, `bob`) from AWS. This helps avoid the need to rely on human\nmemory or terminal copypasta.\n\nAdditionally, all of the bash-my-aws commands are available as completions\nfor the `bma` command, so `bma[tab][tab]` will produce a list of all of the\navailable commands.\n\n### Unix Pipeline Friendly\n\nThe commands themselves are line oriented and work nicely in unix pipelines\nwith other unix commands (e.g. `grep`, `awk`, etc).\n\n```shell\n$ stacks | grep postgres\npostgres01  CREATE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\npostgres02  CREATE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\n```\n\nThey also work incredibly well with each other due to the way they treat input\nfrom STDIN. The first token from each line of STDIN is taken to be a resource\nidentifier (and the rest is discarded).\n\n```shell\n$ stacks | grep postgres | stack-delete\nYou are about to delete the following stacks:\npostgres01\npostgres02\nAre you sure you want to continue? y\n```\n\n*Some users have compared this User Experience to functionality in Windows Powershell.*\n\n### Convenient Shortcuts\n\nBash-my-AWS is insanely simple to pick up and start using but contains a lot of\nconvenient shortcuts you can make use of.\n\nExample: resource listing commands accept a filter argument, removing the need\nfor `| grep`.\n\nIn the following example someone has given a CloudFormation stack a really long name:\n\n```shell\n$ stacks\nnagios                             CREATE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\npostgres01                         DELETE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\npostgres02                         DELETE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\nprometheus                         CREATE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\nstack-with-a-annoyingly-long-name  CREATE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\n```\n\nThis affects the output when we look at our Postgres stacks:\n\n```shell\n$ stacks | grep postgres\npostgres01                         DELETE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\npostgres02                         DELETE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\n```\n\nThe resource listing command can filter output before applying `column`.\n\n```shell\n$ stacks postgres\npostgres01  DELETE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\npostgres02  DELETE_COMPLETE  2011-05-23T15:47:44Z  NEVER_UPDATED  NOT_NESTED\n```\n\n## Quickstart\n\n### Prerequisites\n\n- [awscli](http://aws.amazon.com/cli/)\n- [bash](https://www.gnu.org/software/bash/)\n- [jq-1.4](http://stedolan.github.io/jq/download/) or later (for stack-diff)\n\n### Optional Packages\n\n- [colordiff](https://www.colordiff.org/) to show stack-diff in color\n- [icdiff](https://github.com/jeffkaufman/icdiff) to show stack-diff in color and side-by-side\n\n### Installation\n\nAs shown below, you may simply clone the GitHub repo and source the files required.\n(You should probably fork it instead to keep your customisations)\n\n```Shell\ngit clone https://github.com/bash-my-aws/bash-my-aws.git ${BMA_HOME:-$HOME/.bash-my-aws}\n```\n\nPut the following in your shell's startup file:\n\n```Shell\nexport PATH=\"$PATH:${BMA_HOME:-$HOME/.bash-my-aws}/bin\"\nexport BMA_COLUMNISE_ONLY_WHEN_TERMINAL_PRESENT=true\nsource ${BMA_HOME:-$HOME/.bash-my-aws}/aliases\n\n# For ZSH users, uncomment the following two lines:\n# autoload -U +X compinit \u0026\u0026 compinit\n# autoload -U +X bashcompinit \u0026\u0026 bashcompinit\n\nsource ${BMA_HOME:-$HOME/.bash-my-aws}/bash_completion.sh\n```\n\n#### Why use shell aliases?\n\n`Bash-my-AWS` began as a collection of bash functions, sourced into your shell.\nMore recently, the default suggestion has been to load aliases that execute a\nsmall wrapper script that loads the functions and executes the desired function.\n\nAfter years of `zsh` users asking for support, one stepped up and identified\na changes that would eliminate any shell compatibility problems without compromising\nthe functionaility, simplicity and discoverability of the project. Massive thanks\nto [@ninth-dev](https://github.com/ninth-dev) for this.\n\n```Shell\n    # bash users may source the functions instead of loading the aliases\n    if [ -d ${BMA_HOME:-$HOME/.bash-my-aws} ]; then\n      for f in ${BMA_HOME:-$HOME/.bash-my-aws}/lib/*-functions; do source $f; done\n    fi\n```\n\n## Usage\n\n### Running Commands\n\nThe default way to run the commands is using the aliases:\n\n```ShellSession\n$ instances\ni-e6f097f6ea4457757  ami-123456789012  t3.nano  running  example-ec2-ap-southeast-2  2019-12-07T08:12:00.000Z  ap-southeast-2a  None\ni-b983805b4b254f749  ami-123456789012  t3.nano  running  postfix-prod                2019-12-07T08:26:30.000Z  ap-southeast-2a  None\ni-fed39ebe7204dfd37  ami-123456789012  t3.nano  running  postfix-prod                2019-12-07T08:26:34.000Z  ap-southeast-2a  None\ni-47955eb46d98b4dd8  ami-123456789012  t3.nano  running  prometheus                  2019-12-07T08:27:02.000Z  ap-southeast-2a  None\ni-8d25b78d40d17f38a  ami-123456789012  t3.nano  running  plex-server                 2019-12-07T08:27:38.000Z  ap-southeast-2a  None\n```\n\nIt's also possible to run them using the `bma` wrapper.\n(This is sometimes required when using a restrictive auth tool.)\n\n```ShellSession\n$ bma instances\ni-e6f097f6ea4457757  ami-123456789012  t3.nano  running  example-ec2-ap-southeast-2  2019-12-07T08:12:00.000Z  ap-southeast-2a  None\ni-b983805b4b254f749  ami-123456789012  t3.nano  running  postfix-prod                2019-12-07T08:26:30.000Z  ap-southeast-2a  None\ni-fed39ebe7204dfd37  ami-123456789012  t3.nano  running  postfix-prod                2019-12-07T08:26:34.000Z  ap-southeast-2a  None\ni-47955eb46d98b4dd8  ami-123456789012  t3.nano  running  prometheus                  2019-12-07T08:27:02.000Z  ap-southeast-2a  None\ni-8d25b78d40d17f38a  ami-123456789012  t3.nano  running  plex-server                 2019-12-07T08:27:38.000Z  ap-southeast-2a  None\n```\n\n### Discovering Commands\n\nFor each resource type, there is a command to list them:\n\n```shell\n$ instances\ni-e6f097f6ea4457757  ami-123456789012  t3.nano  running  example-ec2-ap-southeast-2  2019-12-07T08:12:00.000Z  ap-southeast-2a  None\ni-b983805b4b254f749  ami-123456789012  t3.nano  running  postfix-prod                2019-12-07T08:26:30.000Z  ap-southeast-2a  None\ni-fed39ebe7204dfd37  ami-123456789012  t3.nano  running  postfix-prod                2019-12-07T08:26:34.000Z  ap-southeast-2a  None\ni-47955eb46d98b4dd8  ami-123456789012  t3.nano  running  prometheus                  2019-12-07T08:27:02.000Z  ap-southeast-2a  None\ni-8d25b78d40d17f38a  ami-123456789012  t3.nano  running  plex-server                 2019-12-07T08:27:38.000Z  ap-southeast-2a  None\n```\n\nand a number of commands to act on these resources:\n\n```ShellSession\n$ instance-[TAB][TAB]\ninstance-asg          instance-ssh-details  instance-termination-protection\ninstance-az           instance-stack        instance-termination-protection-disable\ninstance-console      instance-start        instance-termination-protection-enable\ninstance-dns          instance-state        instance-type\ninstance-iam-profile  instance-stop         instance-userdata\ninstance-ip           instance-tags         instance-volumes\ninstance-ssh          instance-terminate    instance-vpc\n```\n\nWhether you're new to the tools or just have a bad memory, bash completion\nmakes discovering these commands simple.\n\nSee the [Command Reference](https://bash-my-aws.org/command-reference/) for a full list of commands and usage examples.\n\n### Piping Between Commands\n\nThis is where the magic happens!\n\nThe first token on each line is almost always a resource identifier. When you pipe output\nbetween the commands they just take the first token from each line.\n\n```ShellSession\n$ instances | grep postfix | instance-ip\ni-b983805b4b254f749  10.190.1.70    54.214.71.51\ni-fed39ebe7204dfd37  10.135.204.82  54.214.26.190\n```\n\n!!! Note\n    Most commands that list resources (`stacks`, `instances` , etc) accept\n    filter term as first arg. As well as reducing keystrokes, it can also\n    improve output as columnisation is done after filtering.\n\n        $ instances postfix | instance-ip\n        i-b983805b4b254f749  10.190.1.70    54.214.71.51\n        i-fed39ebe7204dfd37  10.135.204.82  54.214.26.190\n\n### Inspecting Commands\n\nFor those interested in how it works:\n\n- Each command is a bash function.\n- Most are *very* simple and wrap an AWSCLI command.\n\nFor a quick look at how a command works, you can use `bma type`:\n\n```shell\n$ bma type instances\ninstances is a function\ninstances () \n{ \n    local instance_ids=$(__bma_read_inputs);\n    local filters=$(__bma_read_filters $@);\n    aws ec2 describe-instances $([[ -n ${instance_ids} ]] \u0026\u0026 echo --instance-ids ${instance_ids}) --query \"\n      Reservations[].Instances[][\n        InstanceId,\n        ImageId,\n        InstanceType,\n        State.Name,\n        [Tags[?Key=='Name'].Value][0][0],\n        LaunchTime,\n        Placement.AvailabilityZone,\n        VpcId\n      ]\" --output text | grep -E -- \"$filters\" | LC_ALL=C sort -b -k 6 | column -s' ' -t\n}\n```\n\nA prettier version can be found in the source code:\n\n```shell\n# ~/.bash-my-aws/lib/instance-functions\ninstances() {\n  local instance_ids=$(__bma_read_inputs)\n  local filters=$(__bma_read_filters $@)\n\n  aws ec2 describe-instances                                            \\\n    $([[ -n ${instance_ids} ]] \u0026\u0026 echo --instance-ids ${instance_ids})  \\\n    --query \"\n      Reservations[].Instances[][\n        InstanceId,\n        ImageId,\n        InstanceType,\n        State.Name,\n        [Tags[?Key=='Name'].Value][0][0],\n        LaunchTime,\n        Placement.AvailabilityZone,\n        VpcId\n      ]\"                                                               \\\n    --output text       |\n  grep -E -- \"$filters\" |\n  LC_ALL=C sort -b -k 6 |\n  columnise\n}\n```\n\nFor more info on AWSCLI query syntax, check out [http://jmespath.org/tutorial.html](http://jmespath.org/tutorial.html)\n","funding_links":[],"categories":["Shell","cli"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbash-my-aws%2Fbash-my-aws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbash-my-aws%2Fbash-my-aws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbash-my-aws%2Fbash-my-aws/lists"}