AWS
AWS CLI Commands Cheat Sheet
Practical AWS CLI commands for EC2, S3, IAM, VPC, ECR, ECS, EKS, Lambda, RDS, CloudWatch, Route 53, Systems Manager, security, troubleshooting and CI/CD automation.
Showing 178 commands.
AWS CLI Setup and Configuration
aws --versionDisplay the installed AWS CLI version.
aws configureConfigure the default AWS access key, secret key, region and output format.
aws configure listShow the credentials, profile and region currently being used.
aws configure get regionDisplay the configured default AWS region.
aws configure set region ap-south-1Set the default AWS region to Mumbai (ap-south-1).
aws configure list-profilesList all configured AWS CLI profiles.
aws sts get-caller-identityShow the AWS account, user or role associated with the current credentials.
aws sts get-caller-identity --profile devCheck the AWS identity associated with a specific profile.
aws helpDisplay general AWS CLI help.
aws ec2 helpDisplay help for the EC2 service.
AWS Profiles and Regions
aws s3 ls --profile devRun an AWS command using a specific CLI profile.
aws ec2 describe-instances --region ap-south-1Run an EC2 command against a specific AWS region.
aws ec2 describe-regionsList AWS regions available to the account.
aws ec2 describe-availability-zones --region ap-south-1List Availability Zones in the selected region.
EC2 Instances
aws ec2 describe-instancesList and inspect EC2 instances.
aws ec2 describe-instances --instance-ids i-0123456789abcdef0Retrieve information about a specific EC2 instance.
aws ec2 describe-instances --filters Name=instance-state-name,Values=runningList only EC2 instances that are currently running.
aws ec2 describe-instances --filters Name=instance-state-name,Values=stoppedList stopped EC2 instances.
aws ec2 start-instances --instance-ids i-0123456789abcdef0Start a stopped EC2 instance.
aws ec2 stop-instances --instance-ids i-0123456789abcdef0Stop a running EC2 instance.
aws ec2 reboot-instances --instance-ids i-0123456789abcdef0Reboot an EC2 instance.
aws ec2 terminate-instances --instance-ids i-0123456789abcdef0Terminate an EC2 instance.
aws ec2 describe-instance-status --instance-ids i-0123456789abcdef0Check EC2 system and instance status checks.
EC2 AMIs and Snapshots
aws ec2 describe-images --owners selfList AMIs owned by the current AWS account.
aws ec2 describe-images --owners amazonList Amazon-owned AMIs visible to the account.
aws ec2 create-image --instance-id i-0123456789abcdef0 --name my-server-amiCreate an AMI from an EC2 instance.
aws ec2 deregister-image --image-id ami-0123456789abcdef0Deregister an AMI.
aws ec2 describe-snapshots --owner-ids selfList EBS snapshots owned by the current account.
aws ec2 create-snapshot --volume-id vol-0123456789abcdef0 --description "Application backup"Create an EBS snapshot from a volume.
aws ec2 delete-snapshot --snapshot-id snap-0123456789abcdef0Delete an EBS snapshot.
EC2 Key Pairs
aws ec2 describe-key-pairsList EC2 key pairs.
aws ec2 describe-key-pairs --key-names my-keyDisplay information about a specific key pair.
aws ec2 create-key-pair --key-name my-keyCreate an EC2 key pair and return the private key material.
aws ec2 delete-key-pair --key-name my-keyDelete an EC2 key pair from AWS.
EC2 Security Groups
aws ec2 describe-security-groupsList EC2 security groups.
aws ec2 describe-security-groups --group-ids sg-0123456789abcdef0Display the rules and configuration of a specific security group.
aws ec2 authorize-security-group-ingress --group-id sg-0123456789abcdef0 --protocol tcp --port 22 --cidr 203.0.113.10/32Add an inbound TCP rule to a security group.
aws ec2 revoke-security-group-ingress --group-id sg-0123456789abcdef0 --protocol tcp --port 22 --cidr 203.0.113.10/32Remove an inbound security group rule.
aws ec2 authorize-security-group-egress --group-id sg-0123456789abcdef0 --protocol tcp --port 443 --cidr 0.0.0.0/0Add an outbound TCP rule to a security group.
EBS Volumes
aws ec2 describe-volumesList EBS volumes.
aws ec2 describe-volumes --volume-ids vol-0123456789abcdef0Display details about a specific EBS volume.
aws ec2 create-volume --availability-zone ap-south-1a --size 20 --volume-type gp3Create a 20 GiB gp3 EBS volume.
aws ec2 modify-volume --volume-id vol-0123456789abcdef0 --size 40Modify the size of an EBS volume.
aws ec2 delete-volume --volume-id vol-0123456789abcdef0Delete an EBS volume that is no longer required.
Elastic IP Addresses
aws ec2 describe-addressesList Elastic IP addresses allocated to the account.
aws ec2 allocate-address --domain vpcAllocate a new Elastic IP address for use with a VPC.
aws ec2 associate-address --instance-id i-0123456789abcdef0 --allocation-id eipalloc-0123456789abcdef0Associate an Elastic IP address with an EC2 instance.
aws ec2 release-address --allocation-id eipalloc-0123456789abcdef0Release an Elastic IP address.
S3 Buckets
aws s3 lsList S3 buckets.
aws s3 ls s3://my-bucketList objects in an S3 bucket.
aws s3 mb s3://my-bucketCreate an S3 bucket.
aws s3 rb s3://my-bucketRemove an empty S3 bucket.
aws s3 rb s3://my-bucket --forceRemove an S3 bucket and its objects. Use with caution.
aws s3api get-bucket-location --bucket my-bucketCheck the AWS region associated with an S3 bucket.
aws s3api get-bucket-versioning --bucket my-bucketCheck whether S3 versioning is enabled.
S3 Files and Sync
aws s3 cp file.txt s3://my-bucket/Upload a local file to S3.
aws s3 cp s3://my-bucket/file.txt .Download an object from S3.
aws s3 cp ./app s3://my-bucket/app --recursiveUpload a directory and its contents to S3.
aws s3 sync ./build s3://my-bucket/buildSynchronize a local directory with an S3 prefix.
aws s3 sync s3://my-bucket/build ./buildSynchronize an S3 prefix with a local directory.
aws s3 rm s3://my-bucket/file.txtDelete an S3 object.
aws s3 rm s3://my-bucket/logs/ --recursiveDelete objects under an S3 prefix.
aws s3 cp file.txt s3://my-bucket/ --storage-class STANDARD_IAUpload an object using a specified S3 storage class.
IAM Users and Roles
aws iam list-usersList IAM users.
aws iam get-userRetrieve information about the current IAM user when applicable.
aws iam list-rolesList IAM roles.
aws iam get-role --role-name MyRoleDisplay information about an IAM role.
aws iam list-attached-role-policies --role-name MyRoleList managed policies attached to an IAM role.
aws iam list-role-policies --role-name MyRoleList inline policies attached to an IAM role.
aws iam list-attached-user-policies --user-name my-userList managed policies attached to an IAM user.
IAM Policies
aws iam list-policiesList IAM policies visible to the account.
aws iam get-policy --policy-arn arn:aws:iam::123456789012:policy/MyPolicyRetrieve metadata about an IAM policy.
aws iam list-policy-versions --policy-arn arn:aws:iam::123456789012:policy/MyPolicyList versions of an IAM managed policy.
aws iam get-policy-version --policy-arn arn:aws:iam::123456789012:policy/MyPolicy --version-id v1Retrieve the document for a specific IAM policy version.
aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::123456789012:role/MyRole --action-names s3:GetObject --resource-arns arn:aws:s3:::my-bucket/*Simulate whether a principal is allowed to perform a specific action.
IAM Access Keys
aws iam list-access-keys --user-name my-userList access keys associated with an IAM user.
aws iam create-access-key --user-name my-userCreate an access key for an IAM user. Handle credentials securely.
aws iam update-access-key --user-name my-user --access-key-id AKIAEXAMPLE --status InactiveDeactivate an IAM access key.
aws iam delete-access-key --user-name my-user --access-key-id AKIAEXAMPLEDelete an IAM access key.
VPC and Networking
aws ec2 describe-vpcsList VPCs.
aws ec2 describe-subnetsList VPC subnets.
aws ec2 describe-route-tablesList route tables.
aws ec2 describe-internet-gatewaysList Internet Gateways.
aws ec2 describe-nat-gatewaysList NAT Gateways.
aws ec2 describe-network-interfacesList Elastic Network Interfaces.
aws ec2 describe-network-aclsList network ACLs configured in the VPC.
Elastic Load Balancing
aws elbv2 describe-load-balancersList Application Load Balancers and Network Load Balancers.
aws elbv2 describe-target-groupsList Elastic Load Balancing target groups.
aws elbv2 describe-target-health --target-group-arn TARGET_GROUP_ARNCheck the health of targets registered with a target group.
aws elbv2 describe-listeners --load-balancer-arn LOAD_BALANCER_ARNList listeners configured on a load balancer.
Auto Scaling
aws autoscaling describe-auto-scaling-groupsList Auto Scaling groups.
aws autoscaling describe-auto-scaling-instancesList instances managed by Auto Scaling.
aws autoscaling set-desired-capacity --auto-scaling-group-name my-asg --desired-capacity 3Set the desired capacity of an Auto Scaling group.
aws autoscaling update-auto-scaling-group --auto-scaling-group-name my-asg --min-size 2 --max-size 5Update the minimum and maximum capacity of an Auto Scaling group.
ECR
aws ecr describe-repositoriesList Amazon ECR repositories.
aws ecr create-repository --repository-name myappCreate an ECR repository.
aws ecr get-login-password --region ap-south-1Generate a temporary authentication password for an ECR registry.
aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin ACCOUNT_ID.dkr.ecr.ap-south-1.amazonaws.comAuthenticate Docker with an Amazon ECR registry.
aws ecr list-images --repository-name myappList images stored in an ECR repository.
aws ecr describe-images --repository-name myappDisplay metadata about images stored in ECR.
aws ecr batch-delete-image --repository-name myapp --image-ids imageTag=latestDelete an image from an ECR repository.
ECS
aws ecs list-clustersList ECS clusters.
aws ecs describe-clusters --clusters my-clusterDisplay information about an ECS cluster.
aws ecs list-services --cluster my-clusterList services running in an ECS cluster.
aws ecs describe-services --cluster my-cluster --services my-serviceDisplay ECS service configuration and deployment information.
aws ecs list-tasks --cluster my-clusterList running or stopped ECS tasks.
aws ecs describe-tasks --cluster my-cluster --tasks TASK_ARNDisplay detailed information about an ECS task.
aws ecs update-service --cluster my-cluster --service my-service --force-new-deploymentForce a new ECS service deployment using the current task definition.
EKS
aws eks list-clustersList EKS clusters.
aws eks describe-cluster --name my-clusterDisplay configuration and status information for an EKS cluster.
aws eks list-nodegroups --cluster-name my-clusterList managed node groups in an EKS cluster.
aws eks describe-nodegroup --cluster-name my-cluster --nodegroup-name my-nodegroupDisplay information about an EKS managed node group.
aws eks update-kubeconfig --region ap-south-1 --name my-clusterConfigure kubectl to connect to an EKS cluster.
aws eks update-kubeconfig --region ap-south-1 --name my-cluster --alias production-eksAdd an EKS cluster to kubeconfig using a custom context alias.
Lambda
aws lambda list-functionsList Lambda functions.
aws lambda get-function --function-name my-functionRetrieve Lambda function configuration and deployment information.
aws lambda invoke --function-name my-function response.jsonInvoke a Lambda function and save the response.
aws lambda update-function-code --function-name my-function --zip-file fileb://function.zipUpdate Lambda function code from a ZIP package.
aws lambda publish-version --function-name my-functionPublish a new immutable version of a Lambda function.
aws lambda list-versions-by-function --function-name my-functionList published versions of a Lambda function.
aws lambda delete-function --function-name my-functionDelete a Lambda function.
RDS
aws rds describe-db-instancesList RDS database instances.
aws rds describe-db-instances --db-instance-identifier mydbDisplay details about a specific RDS database instance.
aws rds describe-db-clustersList RDS database clusters.
aws rds reboot-db-instance --db-instance-identifier mydbReboot an RDS database instance.
aws rds stop-db-instance --db-instance-identifier mydbStop an RDS database instance when supported by its configuration.
aws rds create-db-snapshot --db-instance-identifier mydb --db-snapshot-identifier mydb-backupCreate a manual RDS database snapshot.
aws rds describe-db-snapshots --db-instance-identifier mydbList snapshots associated with an RDS instance.
CloudWatch Metrics
aws cloudwatch list-metricsList CloudWatch metrics.
aws cloudwatch list-metrics --namespace AWS/EC2List metrics from the EC2 CloudWatch namespace.
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization --dimensions Name=InstanceId,Value=i-0123456789abcdef0 --statistics Average --period 300 --start-time 2026-09-20T10:00:00Z --end-time 2026-09-20T11:00:00ZRetrieve historical CPU utilization statistics for an EC2 instance.
aws cloudwatch describe-alarmsList CloudWatch alarms.
aws cloudwatch describe-alarms-for-metric --metric-name CPUUtilization --namespace AWS/EC2 --dimensions Name=InstanceId,Value=i-0123456789abcdef0Find alarms associated with a specific CloudWatch metric.
CloudWatch Logs
aws logs describe-log-groupsList CloudWatch Logs log groups.
aws logs describe-log-streams --log-group-name /aws/lambda/my-functionList log streams in a CloudWatch log group.
aws logs tail /aws/lambda/my-function --followStream recent CloudWatch log events from a log group.
aws logs tail /aws/lambda/my-function --since 1hDisplay recent CloudWatch log events from the previous hour.
Route 53
aws route53 list-hosted-zonesList Route 53 hosted zones.
aws route53 list-resource-record-sets --hosted-zone-id Z123456789List DNS records in a hosted zone.
aws route53 list-health-checksList Route 53 health checks.
aws route53 get-health-check-status --health-check-id HEALTH_CHECK_IDCheck the status of a Route 53 health check.
Systems Manager
aws ssm describe-instance-informationList managed instances registered with Systems Manager.
aws ssm send-command --instance-ids i-0123456789abcdef0 --document-name AWS-RunShellScript --parameters commands='uname -a'Execute a shell command remotely through Systems Manager.
aws ssm list-command-invocationsList Systems Manager command invocations.
aws ssm get-command-invocation --command-id COMMAND_ID --instance-id i-0123456789abcdef0Retrieve the output and status of a Systems Manager command.
aws ssm start-session --target i-0123456789abcdef0Start an interactive Systems Manager session with a managed EC2 instance.
Secrets Manager
aws secretsmanager list-secretsList secrets available to the current AWS identity.
aws secretsmanager describe-secret --secret-id my-secretDisplay metadata about a secret.
aws secretsmanager get-secret-value --secret-id my-secretRetrieve the current value of a secret when permitted.
CloudFormation
aws cloudformation list-stacksList CloudFormation stacks.
aws cloudformation describe-stacks --stack-name my-stackDisplay CloudFormation stack details.
aws cloudformation describe-stack-events --stack-name my-stackDisplay stack events useful for troubleshooting deployments.
aws cloudformation describe-stack-resources --stack-name my-stackList resources created by a CloudFormation stack.
CloudTrail
aws cloudtrail describe-trailsList CloudTrail trails.
aws cloudtrail get-trail-status --name my-trailCheck the current status of a CloudTrail trail.
aws cloudtrail lookup-events --max-results 50Search recent CloudTrail events.
AWS Resource Tagging
aws resourcegroupstaggingapi get-resourcesList tagged resources available through the Resource Groups Tagging API.
aws resourcegroupstaggingapi get-resources --tag-filters Key=Environment,Values=productionFind resources using a specific tag filter.
AWS Cost and Usage
aws ce get-cost-and-usage --time-period Start=2026-09-01,End=2026-10-01 --granularity MONTHLY --metrics UnblendedCostRetrieve cost and usage data for a specified time period.
aws budgets describe-budgets --account-id 123456789012List AWS Budgets configured for an account.
Useful JSON and Output Options
aws ec2 describe-instances --output jsonReturn AWS CLI output as JSON.
aws ec2 describe-instances --output tableDisplay AWS CLI output in a table.
aws ec2 describe-instances --output textReturn AWS CLI output as tab-separated text.
aws ec2 describe-instances --query 'Reservations[].Instances[].InstanceId'Use JMESPath to extract specific fields from AWS CLI output.
aws ec2 describe-instances --query 'Reservations[].Instances[].{ID:InstanceId,State:State.Name}' --output tableExtract selected EC2 fields and display them as a table.
AWS CLI Troubleshooting
aws sts get-caller-identityVerify which AWS identity is currently being used.
aws configure listCheck which credentials, region and profile configuration are active.
aws ec2 describe-instances --region ap-south-1Check whether a resource is being searched in the expected region.
aws s3 ls --debugEnable AWS CLI debug logging when troubleshooting authentication or API problems.
aws sts get-caller-identity --profile productionVerify credentials for a specific AWS profile.
CI/CD AWS Workflow
aws sts get-caller-identityVerify AWS credentials at the beginning of a CI/CD job.
aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin ACCOUNT_ID.dkr.ecr.ap-south-1.amazonaws.comAuthenticate Docker with an Amazon ECR registry.
docker build -t myapp:$BUILD_NUMBER .Build a Docker image using a CI build number as the tag.
docker tag myapp:$BUILD_NUMBER ACCOUNT_ID.dkr.ecr.ap-south-1.amazonaws.com/myapp:$BUILD_NUMBERTag the Docker image for the ECR repository.
docker push ACCOUNT_ID.dkr.ecr.ap-south-1.amazonaws.com/myapp:$BUILD_NUMBERPush a CI-built Docker image to Amazon ECR.
aws eks update-kubeconfig --region ap-south-1 --name productionConfigure kubectl access to an EKS cluster in a deployment pipeline.
kubectl apply -f k8s/Deploy Kubernetes manifests after configuring EKS access.
kubectl rollout status deployment/myappWait for the Kubernetes deployment rollout to complete.
Recommended AWS DevOps Workflow
# Check AWS identity aws sts get-caller-identity # Configure ECR authentication aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin ACCOUNT_ID.dkr.ecr.ap-south-1.amazonaws.com # Build application image docker build -t myapp:$BUILD_NUMBER . # Tag image docker tag myapp:$BUILD_NUMBER ACCOUNT_ID.dkr.ecr.ap-south-1.amazonaws.com/myapp:$BUILD_NUMBER # Push image docker push ACCOUNT_ID.dkr.ecr.ap-south-1.amazonaws.com/myapp:$BUILD_NUMBER # Configure EKS access aws eks update-kubeconfig --region ap-south-1 --name production # Deploy application kubectl apply -f k8s/ # Check deployment kubectl get pods # Check rollout kubectl rollout status deployment/myapp
DevOpsCommands Tip
Avoid putting long-lived AWS access keys directly into Jenkins, GitHub Actions or other CI/CD configuration. Prefer short-lived credentials and IAM roles where the deployment environment supports them.