Skip to main content

AWS CLI Cheats

Cheat sheet for AWS CLI commands.

info

This page was automatically generated from a navi cheat file available at difranca/navi-cheats.
Navi is an interactive cheatsheet tool for the command-line. To learn more about it, visit denisidoro/navi.


Configโ€‹

Configure AWS CLI profiles and credentials.

CommandDescription
aws configure --profile {profile_name}Configure a new profile
aws configure list-profilesList configured profiles
aws configure list --profile {profile}Show current configuration
aws sts get-caller-identity --profile {profile}Get caller identity (whoami)

S3โ€‹

Manage S3 buckets and objects.

CommandDescription
aws s3 ls --profile {profile}List buckets
aws s3 ls s3://{bucket} --profile {profile}List objects in a bucket
aws s3 ls s3://{bucket} --recursive --profile {profile}List objects recursively
aws s3 cp {local_file} s3://{bucket}/{key} --profile {profile}Copy a file to S3
aws s3 cp s3://{bucket}/{key} {local_path} --profile {profile}Copy a file from S3
aws s3 sync {local_dir} s3://{bucket}/{prefix} --profile {profile}Sync a local directory to S3
aws s3 rm s3://{bucket}/{key} --profile {profile}Remove an object from S3
aws s3 presign s3://{bucket}/{key} --expires-in {seconds} --profile {profile}Generate a presigned URL (expires in seconds)

EC2โ€‹

Manage EC2 instances.

CommandDescription
**aws ec2 describe-instances --profile {profile} --query 'Reservations[].Instances[].[InstanceId, Tags[?Key==Name].Value[0], State.Name, InstanceType]' --output table**
aws ec2 start-instances --instance-ids {instance_id} --profile {profile}Start an instance
aws ec2 stop-instances --instance-ids {instance_id} --profile {profile}Stop an instance
aws ec2 describe-security-groups --profile {profile} --query 'SecurityGroups[].[GroupId, GroupName]' --output tableList security groups
aws ec2 describe-images --owners self --profile {profile} --query 'Images[].[ImageId, Name]' --output tableList available AMIs owned by self

IAMโ€‹

Manage IAM users, roles, and policies.

CommandDescription
aws iam list-users --profile {profile} --query 'Users[].[UserName, CreateDate]' --output tableList users
aws iam list-roles --profile {profile} --query 'Roles[].[RoleName, Arn]' --output tableList roles
aws iam list-attached-role-policies --role-name {role_name} --profile {profile}List policies attached to a role
aws iam get-role --role-name {role_name} --profile {profile}Get role details

Lambdaโ€‹

Manage Lambda functions.

CommandDescription
aws lambda list-functions --profile {profile} --query 'Functions[].[FunctionName, Runtime, LastModified]' --output tableList functions
aws lambda invoke --function-name {function_name} --profile {profile} /dev/stdoutInvoke a function
aws lambda invoke --function-name {function_name} --payload '{json_payload}' --profile {profile} /dev/stdoutInvoke a function with payload
aws lambda get-function-configuration --function-name {function_name} --profile {profile}Get function configuration
aws logs tail /aws/lambda/{function_name} --since 5m --profile {profile}View function logs (last 5 minutes)

CloudWatch Logsโ€‹

View and search logs.

CommandDescription
aws logs describe-log-groups --profile {profile} --query 'logGroups[].[logGroupName]' --output tableList log groups
aws logs tail {log_group} --follow --profile {profile}Tail logs in real time
aws logs tail {log_group} --since {duration} --profile {profile}Tail logs since a time period
aws logs filter-log-events --log-group-name {log_group} --filter-pattern '{pattern}' --profile {profile}Filter log events

EKSโ€‹

Manage Elastic Kubernetes Service clusters.

CommandDescription
aws eks list-clusters --profile {profile} --output tableList EKS clusters
aws eks describe-cluster --name {cluster} --profile {profile}Describe a cluster
aws eks update-kubeconfig --name {cluster} --profile {profile}Update kubeconfig for a cluster
aws eks update-kubeconfig --name {cluster} --alias {alias} --profile {profile}Update kubeconfig with a specific alias
aws eks list-nodegroups --cluster-name {cluster} --profile {profile}List nodegroups in a cluster
aws eks describe-nodegroup --cluster-name {cluster} --nodegroup-name {nodegroup} --profile {profile}Describe a nodegroup
aws eks list-fargate-profiles --cluster-name {cluster} --profile {profile}List Fargate profiles
aws eks list-addons --cluster-name {cluster} --profile {profile}List addons for a cluster

ECRโ€‹

Manage Elastic Container Registry.

CommandDescription
**aws ecr get-login-password --profile {profile}docker login --username AWS --password-stdin {account_id}.dkr.ecr.{region}.amazonaws.com**
aws ecr describe-repositories --profile {profile} --query 'repositories[].[repositoryName, repositoryUri]' --output tableList repositories
aws ecr describe-images --repository-name {ecr_repository} --profile {profile} --query 'imageDetails[].[imageTags[0], imagePushedAt, imageSizeInBytes]' --output tableList images in a repository
aws ecr batch-delete-image --repository-name {ecr_repository} --image-ids imageTag={tag} --profile {profile}Delete an image by tag

CodeArtifactโ€‹

Manage CodeArtifact repositories and packages.

CommandDescription
aws codeartifact list-domains --profile {profile} --output tableList domains
aws codeartifact list-repositories --profile {profile} --output tableList repositories
aws codeartifact list-packages --domain {ca_domain} --repository {ca_repository} --profile {profile}List packages in a repository
aws codeartifact get-authorization-token --domain {ca_domain} --profile {profile} --query authorizationToken --output textGet authorization token for a domain
aws codeartifact get-repository-endpoint --domain {ca_domain} --repository {ca_repository} --format {package_format} --profile {profile}Get repository endpoint
aws codeartifact login --tool pip --domain {ca_domain} --repository {ca_repository} --profile {profile}Login to CodeArtifact (pip)
aws codeartifact login --tool npm --domain {ca_domain} --repository {ca_repository} --profile {profile}Login to CodeArtifact (npm)

Secrets Managerโ€‹

Manage secrets.

CommandDescription
aws secretsmanager list-secrets --profile {profile} --query 'SecretList[].[Name, LastChangedDate]' --output tableList secrets
aws secretsmanager get-secret-value --secret-id {secret_id} --profile {profile} --query SecretString --output textGet a secret value
aws secretsmanager create-secret --name {name} --secret-string '{secret_value}' --profile {profile}Create a secret
aws secretsmanager put-secret-value --secret-id {secret_id} --secret-string '{secret_value}' --profile {profile}Update a secret value
aws secretsmanager delete-secret --secret-id {secret_id} --recovery-window-in-days {days} --profile {profile}Delete a secret (with recovery window)

SSM Parameter Storeโ€‹

Manage Systems Manager parameters.

CommandDescription
aws ssm describe-parameters --profile {profile} --query 'Parameters[].[Name, Type, LastModifiedDate]' --output tableList parameters
aws ssm get-parameter --name {parameter_name} --with-decryption --profile {profile} --query Parameter.Value --output textGet a parameter value
aws ssm get-parameters-by-path --path {path_prefix} --recursive --with-decryption --profile {profile}Get parameters by path
aws ssm put-parameter --name {name} --value '{value}' --type {parameter_type} --profile {profile}Put a parameter
aws ssm delete-parameter --name {parameter_name} --profile {profile}Delete a parameter

SQSโ€‹

Manage Simple Queue Service.

CommandDescription
aws sqs list-queues --profile {profile}List queues
aws sqs send-message --queue-url {queue_url} --message-body '{message}' --profile {profile}Send a message to a queue
aws sqs receive-message --queue-url {queue_url} --max-number-of-messages {count} --profile {profile}Receive messages from a queue
aws sqs get-queue-attributes --queue-url {queue_url} --attribute-names All --profile {profile}Get queue attributes
aws sqs purge-queue --queue-url {queue_url} --profile {profile}Purge a queue

SNSโ€‹

Manage Simple Notification Service.

CommandDescription
aws sns list-topics --profile {profile}List topics
aws sns list-subscriptions-by-topic --topic-arn {topic_arn} --profile {profile}List subscriptions for a topic
aws sns publish --topic-arn {topic_arn} --message '{message}' --profile {profile}Publish a message to a topic

Step Functionsโ€‹

Manage Step Functions state machines.

CommandDescription
aws stepfunctions list-state-machines --profile {profile} --query 'stateMachines[].[name, stateMachineArn]' --output tableList state machines
aws stepfunctions describe-state-machine --state-machine-arn {state_machine_arn} --profile {profile}Describe a state machine
aws stepfunctions start-execution --state-machine-arn {state_machine_arn} --input '{json_input}' --profile {profile}Start an execution
aws stepfunctions list-executions --state-machine-arn {state_machine_arn} --profile {profile} --query 'executions[].[name, status, startDate]' --output tableList executions for a state machine