AWS CLI — Auto-prompt

Bachar Hakam
2 min readNov 24, 2022

--

What is auto-prompt mode?

The AWS CLI is a powerful tool for managing and setting up AWS services and automating them through scripting.

Since we use it in our daily operations, it would be helpful to have a list of the commands for quick reference. Fortunately, AWS CLI has a handy feature that would be helpful when constructing commands. The auto-prompt mode lists the services or options as you type. This would be very useful, especially if you forget a few options.

There are 3 ways to use this feature. I will walk through them with examples.

1- Single command option

AWS CLI option --cli-auto-prompt can be used once per single command.

Example 1.1:

$ aws --cli-auto-prompt
> aws
accessanalyzer Access Analyzer
account AWS Account
acm AWS Certificate Manager
acm-pca AWS Certificate Manager Private Certi...

Example 1.2:

$ aws s3 --cli-auto-prompt
> aws s3
ls
website
cp
mv
rm
sync
mb
rb
presign

2- Using Environment variables

There are 2 settings that can be used to enable auto-prompt mode inside the environment variables.

  • on uses the full auto-prompt mode whenever you run aws command. Useful when you are new to aws commands.

AWS_CLI_AUTO_PROMPT=on

  • on-partial uses partial auto-prompt mode. This mode is particular useful if you have pre-existing scripts, runbooks, or you only want to be auto-prompted for commands you are unfamiliar with rather than prompted on every command.

AWS_CLI_AUTO_PROMPT=on-partial

2.1- How to set auto-prompt inside the environment variables

Windows

  • CMD
c:\> set AWS_CLI_AUTO_PROMPT=on-partial
c:\> set AWS_CLI_AUTO_PROMPT
AWS_CLI_AUTO_PROMPT=on-partial
  • PowerShell or Terminal
C:\> $Env:AWS_CLI_AUTO_PROMPT = 'on-partial'
C:\> $Env:AWS_CLI_AUTO_PROMPT
on-partial

Linux

  • Terminal
$ export AWS_CLI_AUTO_PROMPT="on-partial"

3- Shared config files

You can enable auto-prompt mode per each profile by updating the AWS CLI config file located inside >> (~/.aws/).

Edit the config file then add one of the below settings for each profile.

  • cli_auto_prompt = on

Example:

[profile User1]
region=us-east-1
cli_auto_prompt = on
  • cli_auto_prompt = on-partial

Example:

[profile User2]
region=us-east-1
cli_auto_prompt = on-partial

For more details, you may refer to the AWS CLI User Guide — Auto-prompt.

Please feel free to share your feedback.

--

--

Bachar Hakam

Coffee first! All about coffee; Got attached to bread & baking :: Technical Consultant - AWS Certified