navigation

Getting Started with the AWS CLI

What is AWS CLI?

In this workshop, you will learn about AWS CLI and use it to interact with AWS services.

What is AWS CLI?

ℹ️ Information: AWS Command Line Interface (AWS CLI) is an open-source tool that allows you to interact with AWS services using commands in your command-line shell. With a simple setup process, AWS CLI allows you to run commands that implement functions equivalent to those provided by the AWS Management Console in your browser.

Supported Environments

ℹ️ Information: AWS CLI supports the following command-line environments:

  • Linux shells – Use popular command-line programs like bash, zsh, and tcsh to run commands on Linux or macOS.
  • Windows command line – On Windows, run commands in the Windows command prompt or in PowerShell.
  • Remotely – Run commands on Amazon Elastic Compute Cloud (Amazon EC2) instances through command-line tools like PuTTY or SSH or AWS Systems Manager.

💡 Pro Tip: All administrative, management, and access functions for AWS resources in the AWS Management Console are available in the AWS API and CLI. New AWS features and services will be fully provided like on the AWS Management Console through API and CLI immediately after launch or within 180 days thereafter.

AWS CLI Capabilities

ℹ️ Information: AWS CLI provides direct access to the public APIs of AWS services. You can explore the capabilities of an AWS service with AWS CLI and develop shell scripts to manage your resources. In addition to low-level commands equivalent to APIs, many AWS services allow customizations on AWS CLI. Customizations can include higher-level commands that simplify using services with complex APIs.

Profiles in AWS CLI

ℹ️ Information:

  • A profile is a collection of settings and credentials that allow you to use the commands available in AWS CLI. By default, AWS CLI uses the default profile. Additionally, you can create multiple other profiles called named profiles with the --profile parameter.
  • AWS CLI stores profile information in config and credentials files. You can create additional profiles by adding settings directly to these files.

💡 Pro Tip: With the --profile parameter, you can specify a specific profile to execute commands in AWS CLI. You can also specify a profile in the AWS_PROFILE environment variable to replace the default profile in a specific session.

Basic AWS CLI Configuration

ℹ️ Information: We will use the aws configure command. This is considered the fastest way to set up AWS CLI. The command line will prompt for 4 pieces of information as follows:

  • Access key ID
  • Secret access key
  • AWS Region
  • Output format

Credentials Information

🔒 Security Note: Access keys include access key ID and secret access key, used to sign application requests you send to AWS. Always protect this information and never share it. Use IAM roles when possible instead of access keys.

Region Configuration

ℹ️ Information: Default region name specifies the AWS Region with servers where you want to send your requests by default. For example: you can enter us-west-2 to use US West (Oregon). This is the default Region that all subsequent requests will be sent to, unless you specify otherwise.

⚠️ Warning: Region selection affects cost, latency, and service availability. Choose a Region close to your end users to reduce latency.

Output Format

ℹ️ Information: Default output format specifies how returned results are formatted. If you don’t specify an output format, json is used by default.

  • json – Output is formatted as a JSON string.
  • yaml – Output is formatted as a YAML string. (Only supported in AWS CLI v2.)
  • yaml-stream – Output is streamed and formatted as a YAML string. (Only supported in AWS CLI version 2.)
  • text – Output is formatted as multiple lines of tab-separated string values.
  • table – Output is formatted as a table using +|- characters to form cell borders.

💡 Pro Tip: The table format is very useful when you want to view results visually, while json or yaml formats are suitable when you need to process data with other tools.