LinuxCommandLibrary

aws

Manage Amazon Web Services from the command line

TLDR

Configure the AWS Command-line

$ aws configure wizard
copy

Configure the AWS Command-line using SSO
$ aws configure sso
copy

Get the caller identity (used to troubleshoot permissions)
$ aws sts get-caller-identity
copy

List AWS resources in a region and output in YAML
$ aws dynamodb list-tables --region [us-east-1] --output yaml
copy

Use auto prompt to help with a command
$ aws iam create-user --cli-auto-prompt
copy

Get an interactive wizard for an AWS resource
$ aws dynamodb wizard [new_table]
copy

Generate a JSON CLI Skeleton (useful for infrastructure as code)
$ aws dynamodb update-table --generate-cli-skeleton
copy

Display help for a specific command
$ aws [command] help
copy

SYNOPSIS

aws [options] <command> <subcommand> [parameters]

Example:
aws s3 ls
aws ec2 describe-instances --instance-ids i-1234567890abcdef0
aws lambda invoke --function-name MyFunction --payload '{"key":"value"}' output.json

PARAMETERS

--region
    Specifies the AWS region to send the request to, overriding the default configured region.

--output
    Defines the output format for command results. Common formats include json, text, table, and yaml.

--profile
    Uses a specific named profile from the credentials file (~/.aws/credentials) or config file (~/.aws/config).

--debug
    Turns on debug logging, providing detailed information about the API request and response.

--no-paginate
    Disables the automatic pagination of results for commands that return a large number of items.

--cli-input-json
    Reads input parameters from a JSON string or file instead of command-line arguments.

--version
    Displays the version of the AWS CLI currently installed.

--endpoint-url
    Specifies a custom endpoint URL to send the request to, useful for local testing or private endpoints.

DESCRIPTION

The `aws` command is the official command-line interface (CLI) for interacting with Amazon Web Services (AWS). It provides a unified tool to manage your AWS services from the terminal, enabling powerful automation and scripting capabilities.

With `aws`, users can perform operations such as creating and managing EC2 instances, uploading and downloading files from S3, configuring IAM roles, interacting with databases like RDS and DynamoDB, and orchestrating serverless functions with Lambda. It supports virtually all AWS services and their respective API operations.

Key features include consistent syntax across services, support for various output formats (JSON, text, table, YAML), automatic pagination for large result sets, and the ability to manage multiple AWS profiles. It simplifies cloud resource management, allowing developers and administrators to automate complex workflows and integrate AWS operations into their existing scripts and tools.

CAVEATS

Using the `aws` command requires proper authentication and configuration (credentials and region). Incorrect usage, especially with commands that create, modify, or delete resources, can incur unexpected AWS costs. The vast number of services and subcommands means a significant learning curve to master its full potential. Output parsing for scripting can be complex, often requiring additional tools like `jq`.

CONFIGURATION AND CREDENTIALS

Before using the `aws` command, you typically need to configure your AWS credentials and a default region. This is done using the aws configure command, which prompts you for your AWS Access Key ID, Secret Access Key, default region name, and default output format. These settings are stored in ~/.aws/credentials and ~/.aws/config.

SERVICE-SPECIFIC COMMANDS

The `aws` command itself acts as a dispatcher. All specific AWS operations are nested under service commands (e.g., s3, ec2, lambda) and then further subcommands (e.g., s3 cp, ec2 describe-instances). The full list of available commands and subcommands for any service can be explored using the aws help command or by appending help to any command/subcommand (e.g., aws s3 help).

HISTORY

The AWS CLI was initially released in November 2013, developed by Amazon Web Services to provide a unified and consistent command-line interface across its rapidly expanding suite of cloud services. Before its introduction, users often relied on separate, service-specific command-line tools or SDKs. The `aws` CLI consolidated these, offering a single executable for interacting with virtually every AWS API operation. Its development has been continuous, with frequent updates to support new AWS services, features, and enhancements, making it an indispensable tool for cloud administrators, developers, and DevOps professionals.

SEE ALSO

jq(1), curl(1), grep(1), awk(1), less(1), aws configure

Copied to clipboard