This is a quick memo on how to retrieve all AWS service names (subcommands) provided via AWS CLI.
Introduction
Sometimes you might want to list all the services you can use with AWS CLI, like aws ec2 or aws s3. Here's how to get all of them.
# AWS CLI version $ aws --version aws-cli/2.11.2 Python/3.11.2 Darwin/23.6.0 exe/x86_64 prompt/off
Note: This article was translated from my original post.
How to List All Available Services in AWS CLI
Method
Use the following command to retrieve all service names available in the AWS CLI:
# To get the list of service names aws help | col -bx | sed -n '/AVAILABLE SERVICES/,/SEE ALSO/p' | grep 'o ' | awk '{print $2}' # To get the list of service names as a JSON array aws help | col -bx | sed -n '/AVAILABLE SERVICES/,/SEE ALSO/p' | grep 'o ' | awk '{print $2}' | jq -R . | jq -s .
Here's what each part of the process does:
aws help
The help page of AWS CLI includes a list of all available services. We start by extracting that.col -bx
This command removes the special characters (backspace) and converts tabs into spaces.
Without this step, it's difficult to process the help text properly.
For more details, see: Fixing 'aws help' Output That Won’t Work with 'grep' - BioErrorLog Tech Blog (en)sed -n '/AVAILABLE SERVICES/,/SEE ALSO/p'
Extracts only the section between "AVAILABLE SERVICES" and "SEE ALSO", which contains the list of services.grep 'o '
Filters lines that start with'o ', which are used as bullet points for service names.awk '{print $2}'
Splits each line by whitespace and prints the second field, which is the actual service name.
Each line follows the formato <service-name>, so$1isoand$2is the service name.jq -R .
-Ror--raw-inputtreats each input line as a raw string and converts it to a JSON string.jq -s .
-sor--slurpreads all lines into a single JSON array.
Example
First, using the command to get plain service names:
$ aws help | col -bx | sed -n '/AVAILABLE SERVICES/,/SEE ALSO/p' | grep 'o ' | awk '{print $2}' accessanalyzer account acm acm-pca alexaforbusiness amp amplify # ~omitted~ workdocs worklink workmail workmailmessageflow workspaces workspaces-web xray
The service names are successfully retrieved as plain text.
Next, using the second command to get the list in JSON format:
$ aws help | col -bx | sed -n '/AVAILABLE SERVICES/,/SEE ALSO/p' | grep 'o ' | awk '{print $2}' | jq -R . | jq -s . [ "accessanalyzer", "account", "acm", "acm-pca", "alexaforbusiness", "amp", "amplify", # ~omitted~ "worklink", "workmail", "workmailmessageflow", "workspaces", "workspaces-web", "xray" ]
As you can see, the list of service names is returned as a JSON array.
Conclusion
That's how you can get a full list of available AWS CLI services using simple command-line.
Hope this helps someone.
[Related Article]