Cloud Infrastructure
Updated for 2026

AWS CLI Cheatsheet & Cloud Commands Cheat Sheet

Your cloud companion: AWS CLI cheatsheet and terminal cheat sheet. Explore S3 storage actions, EC2 status queries, security IAM setups, and serverless Lambda listings.

Target Version Compatibility

Interactive Skill Mastery

Mark commands as learned to build your customized reference tracker. Retained locally in this browser.

Level:Novice
Command Mastery Progress0 of 20 Mastered (0%)

Configuration

aws configure
BeginnerBasics
Setup Access Keys, Secret, Default Region, and output format for your developer profile.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws configure

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws configure --profile <profile_name>
BeginnerBasics
Create separate environment credentials using named workspace profiles.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws configure --profile <profile_name>

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws sts get-caller-identity
BeginnerBasics
Verify authentication parameters, active IAM account ID, and credential roles currently in use.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws sts get-caller-identity

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws sts assume-role --role-arn arn:aws:iam::123456789012:role/DeployRole --role-session-name AWSCLI-Session
BeginnerBasics
Assume dynamic identity roles programmatically to retrieve temporary safety credentials.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws sts assume-role --role-arn arn:aws:iam::123456789012:role/DeployRole --role-session-name AWSCLI-Session

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws cloudformation deploy --template-file template.yaml --stack-name production-stack
BeginnerBasics
Validate and trigger multi-resource infrastructure updates securely using CloudFormation templates.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws cloudformation deploy --template-file template.yaml --stack-name production-stack

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws ssm get-parameter --name "/prod/db/pass" --with-decryption
BeginnerBasics
Query the Systems Manager Parameter Store and decrypt sensitive values on the fly.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws ssm get-parameter --name "/prod/db/pass" --with-decryption

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)

S3 Storage

aws s3 ls
BeginnerBasics
List all active S3 buckets registered to your cloud billing account.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws s3 ls

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws s3 mb s3://<bucket-name>
BeginnerBasics
Create a brand new secure S3 storage bucket bucket directory on the cloud.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws s3 mb s3://<bucket-name>

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws s3 cp <local_file> s3://<bucket>/<path>
BeginnerBasics
Copy files directly from local paths to S3 directories, or vice-versa.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws s3 cp <local_file> s3://<bucket>/<path>

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws s3 sync <local_folder> s3://<bucket>/
BeginnerBasics
Sync directory contents recursively to an S3 folder (only uploads new or modified files).

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws s3 sync <local_folder> s3://<bucket>/

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws s3 sync s3://<bucket-src> s3://<bucket-dest>
BeginnerBasics
Perform extremely high-speed direct server-to-server synchronization between two separate S3 bucket locations.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws s3 sync s3://<bucket-src> s3://<bucket-dest>

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)

EC2 Instances

aws ec2 describe-instances --filters "Name=instance-state-name,Values=running"
IntermediateAdvanced
Retrieve diagnostic information for EC2 virtual servers that are active.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws ec2 describe-instances --filters "Name=instance-state-name,Values=running"

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws ec2 start-instances --instance-ids <id>
BeginnerBasics
Trigger startup commands on a stopped virtual machine server.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws ec2 start-instances --instance-ids <id>

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws ec2 terminate-instances --instance-ids <id>
BeginnerBasics
Send an irreversible API termination request to permanently destroy a running virtual machine server.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws ec2 terminate-instances --instance-ids <id>

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)

IAM Security

aws iam list-users
AdvancedSecurity
List all registered IAM security accounts within your organizational tenant.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws iam list-users

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws kms encrypt --key-id 1234abcd-12ab-34cd-56ef-1234567890ab --plaintext fileb://data.txt --output text
AdvancedSecurity
Encrypt raw configuration files using AWS Key Management Service (KMS) master keys securely.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws kms encrypt --key-id 1234abcd-12ab-34cd-56ef-1234567890ab --plaintext fileb://data.txt --output text

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)

Lambda & Services

aws lambda list-functions --max-items 10
BeginnerBasics
Fetch details of active serverless Lambda code functions in the active region.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws lambda list-functions --max-items 10

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws dynamodb scan --table-name <table_name>
BeginnerBasics
Perform a retrieval query scan over a NoSQL DynamoDB database table (returns row objects).

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws dynamodb scan --table-name <table_name>

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws lambda update-function-code --function-name <name> --zip-file fileb://file.zip
BeginnerBasics
Dynamically upload fresh zipped application bundles directly into your serverless Cloud function assets.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws lambda update-function-code --function-name <name> --zip-file fileb://file.zip

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)
aws logs tail /aws/lambda/my-function --follow --format short
IntermediateDebugging
Tail CloudWatch application logs streams interactively directly inside the developer terminal.

When to Use

When managing, querying, or transferring cloud infrastructure files directly from local command shell profiles.

Common Mistakes

Hardcoding active Access Keys or Secret keys inside files (always use IAM service roles or credential profiles instead).

Shortcut / Pro-Tip

Set up named profiles with 'aws configure --profile <name>' to switch between development and production environments.

Example

aws logs tail /aws/lambda/my-function --follow --format short

Output Example

Console / Terminal
Cloud API resource transaction completed successfully. (Returns standardized JSON metadata details)

AWS CLI Best Practices

1Adopt Named Profiles Exclusively

Isolate client projects and access credentials using named workspace profiles (aws configure --profile label).

2Secure Root Access Keys Rigorously

Never generate root user API access keys. Provision least-privileged IAM developer user accounts and assume custom roles instead.

3Configure Safe S3 Transfers

Enable encryption and versioning on target buckets before transferring files using 'aws s3 cp' or sync.

4Format Terminal Outputs cleanly

Request structured, filterable terminal responses by appending --output json or --output table to commands.

5Optimize large queries with jq

Combine AWS CLI filtering queries with command line utilities like jq to parse nested arrays and objects quickly.

Common AWS CLI Errors & Solutions

Error

SignatureDoesNotMatch: Access Key invalid

Solution

Double-check your credentials inside ~/.aws/credentials. Regenerate keys or configure profiles again with correct inputs.

Error

AccessDenied: User not authorized to perform

Solution

Your IAM user account lacks permissions for that cloud command. Add the missing policy permission to the user role in the IAM console.

Error

ExpiredToken: Request has expired

Solution

Your temporary session token (often from AWS SSO or STS) has expired. Re-authenticate using: aws sso login or aws sts.

Error

BucketName already exists globally

Solution

S3 bucket folders share a universal global namespace. Choose a completely unique, randomized name string for your bucket.

Error

Region parameter missing or invalid

Solution

Set the default location parameter in your active profile, or append '--region us-east-1' directly to the active terminal execution.

Common AWS CLI Interview Questions

Q1What is the AWS CLI and what is its primary use case?

The AWS Command Line Interface (CLI) is a unified tool to manage your AWS cloud services from terminal scripts. It allows developers to automate deployments, script object uploads to S3, manage EC2, and configure IAM.

Q2How do you specify distinct user accounts or credentials in the AWS CLI?

By configuring named profiles with 'aws configure --profile <name>'. You can then execute commands for a specific user profile by appending the '--profile' flag to any command.

Q3What is the difference between 'aws s3 cp' and 'aws s3 sync'?

aws s3 cp copies specific individual files or objects between local paths and S3. aws s3 sync recursively compares and synchronizes whole directories, only copying modified or new files to save bandwidth.

Q4How do you filter outputs in AWS CLI without downloading massive JSON payloads?

By utilizing the built-in '--query' parameter, which executes client-side JMESPath queries (e.g. --query 'Reservations[*].Instances[*].InstanceId') to return only specific attributes.

Q5What files store credentials locally and where are they located?

AWS CLI stores configuration parameters and credentials in a hidden directory at the user root (~/.aws/). Key configurations are saved in 'config', and sensitive secret keys are stored in 'credentials'.