Skip to main content

Command Palette

Search for a command to run...

Enabling Autocomplete for AWS CLI

In this article, we'll learn about the AWS CLI prompt feature which allows to autocomplete the AWS CLI commands to minimize documentation reference.

Published
2 min read
Enabling Autocomplete for AWS CLI
G

I am a Cloud Engineer working at AWS to help customers maintain security in the cloud.

Love to play with JavaScript in my free time and write about my learnings to make your tech journey smoother and productive!

AWS CLI is the standard way to interact with AWS services using commands in your command-line shell. AWS has over 200 fully-featured services. So, it is almost impossible to remember every CLI command and their parameters. This requires us to refer the AWS CLI documentation again and again.

The in-built "Auto-prompt" feature provided by AWS CLI (v2) can be easily used to minimise the number of times we refer the CLI documentation.

Note: The AWS CLI (v1) does not support this feature. We can easily check the current version of our AWS CLI using the following command:

aws --version

Auto-prompt in action 🧑‍💻

Just type the partial command that you know, and then click "Enter" to kick-in this feature 👇

aws-cli-blog.gif

Modes of Auto-prompt

Before configuring this, lets talk about the two modes of auto-prompt feature that are provided by AWS CLI:

  • Full mode: This mode uses the auto-prompt feature each time user runs an AWS command which can be either a complete command or an incomplete command. This can be done manually using the --cli-auto-prompt parameter or can be enabled permanently using the configuration file.
  • Partial mode: This mode uses the auto-prompt feature if a command is incomplete or cannot be run due to a client-side validation error. This mode is useful in scenarios where you only want to be auto-prompted for commands you are unfamiliar with rather than prompted on every command.

Recommendation

Based on my experience, the "Partial mode" for this feature is better than the "Full mode". This helps to avoid any unnecessary prompts if the AWS CLI command you are running is already correct.

Configuration

The "auto-prompt" feature can be enabled using the following command:

⭐️ Full mode

aws configure set cli_auto_prompt on

⭐️ Partial mode

aws configure set cli_auto_prompt on-partial

After using the above commands, this feature is only enabled for the AWS CLI default profile.

⭐️ Enabling it for a specific AWS CLI profile

We can enable this for a specific AWS CLI profile using the --profile parameter i.e.

aws configure set cli_auto_prompt on-partial --profile <profile-name>

And thats it. We are done learning another less known but an useful feature while working with AWS.

Now you can enjoy this feature and reduce the amount of time you spend referring to the AWS CLI documentation.

Reference

Having the AWS CLI prompt you for commands


👋 Enjoyed the article? Reach out to me anytime in the comments below or on Twitter for any further discussion or feedback.

AWS

Part 1 of 4

Amazon Web Services is the most popular and comprehensive cloud service provider. In this series, I will write about various concepts and services in AWS to help you understand it better.

Up next

AWS Access Keys - AKIA vs ASIA

In this article, we'll learn about the two types of AWS Access keys which can be used to programmatically access the AWS resources.