Credentials and profiles
aws configure # access key, secret, region, outputaws configure --profile prodaws configure sso # IAM Identity Centeraws sso login --profile prodaws configure list # what's in use, and from whereaws configure list-profilesexport AWS_PROFILE=prod # for this shellaws sts get-caller-identity # who am I, in which accountOrder used: command options, environment variables, ~/.aws/credentials and ~/.aws/config, then the instance or container role.
Output and filters
aws ec2 describe-instances --output tableaws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId,State.Name]' --output textaws ec2 describe-instances --filters 'Name=tag:Name,Values=web*' --query 'Reservations[].Instances[].PrivateIpAddress'aws s3api list-buckets --query 'Buckets[].Name' --output textaws ec2 describe-regions --query 'Regions[].RegionName' --output text--filters filters on AWS’s side; --query (JMESPath) shapes the answer on yours.
S3
aws s3 ls # bucketsaws s3 ls s3://acme-logs/2026/ --recursive --human-readable --summarizeaws s3 cp backup.tar.gz s3://acme-backups/aws s3 cp s3://acme-backups/backup.tar.gz .aws s3 sync ./site s3://acme-site --delete --dryrun # preview, then drop --dryrunaws s3 rm s3://acme-tmp/ --recursiveaws s3 presign s3://acme-backups/backup.tar.gz --expires-in 3600aws s3 mb s3://acme-new-bucketEC2
aws ec2 describe-instances --instance-ids i-0abc123aws ec2 start-instances --instance-ids i-0abc123aws ec2 stop-instances --instance-ids i-0abc123aws ec2 describe-security-groups --group-ids sg-0abc123aws ssm start-session --target i-0abc123 # shell without SSH (Session Manager plugin)Logs and IAM
aws logs tail /aws/lambda/api --follow --since 10maws logs tail /ecs/web --filter-pattern ERRORaws iam list-attached-role-policies --role-name app-roleaws iam simulate-principal-policy --policy-source-arn arn:aws:iam::123456789012:role/app-role \ --action-names s3:GetObject --resource-arns arn:aws:s3:::acme-logs/*Handy options
--region eu-central-1 # override the region--profile prod # override the profile--no-cli-pager # don't open less--debug # every request, signature and answer--endpoint-url http://localhost:4566 # LocalStack or another S3 APICommon errors
Unable to locate credentialsis not authorized to performS3 403 Access DeniedSignatureDoesNotMatch