Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

aws

The AWS CLI v2: manage EC2, S3, IAM, EKS and every other AWS service from the terminal and from pipelines.

Level
DevSecOps service
Group
Infrastructure as Code and cloud
Needs root
No
Package
awscli2

What it does

aws calls the AWS APIs with credentials from a profile (~/.aws/config, ~/.aws/credentials), from IAM Identity Center (SSO), from environment variables, or from the instance/pod role. Every command is aws SERVICE ACTION --options. Output is JSON; --query (JMESPath) and --output table|text make it readable.

Even when your main cloud is Azure, DevOps jobs often ask for basic AWS: S3, EC2, IAM and EKS.

How to write it

aws SERVICE ACTION [--options] [--profile NAME] [--region REGION] [--query EXPR] [--output FORMAT]

Main parts

Most used services

configure / configure sso / sso login
Set up credentials.
sts get-caller-identity
Who am I?
s3 / s3api
Object storage (simple / full API).
ec2
Virtual machines, security groups, VPCs.
iam
Users, roles, policies.
eks
Kubernetes clusters (update-kubeconfig).
ecr
Container registry.
logs
CloudWatch Logs.
cloudformation
Templates.
ssm
Session Manager, Parameter Store.
secretsmanager
Secrets.

Options 7

Most used

Global options

--profile NAME
Use this profile.
--region REGION
Region (eu-central-1, eu-west-1 …).
--output json|table|text|yaml
Output format.
--query EXPR
Pick fields.
--no-cli-pager
No pager (scripts).
--dry-run
Check permissions without doing it (EC2).
--debug
Show the HTTP calls.

Examples 12

$ run as a normal user# run as root (or with sudo)

  1. 1Log in with SSO and check who you are

    aws configure sso --profile lab
    aws sso login --profile lab
    aws sts get-caller-identity --profile lab
  2. 2Work with S3

    aws s3 mb s3://s0sta-lab-backups-2026 --region eu-central-1
    aws s3 cp backup.tar.gz s3://s0sta-lab-backups-2026/daily/
    aws s3 ls s3://s0sta-lab-backups-2026/daily/ --human-readable
    aws s3 sync ./site s3://s0sta-lab-site --delete
  3. 3Block public access and turn on encryption

    aws s3api put-public-access-block --bucket s0sta-lab-backups-2026 --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true
    aws s3api put-bucket-encryption --bucket s0sta-lab-backups-2026 --server-side-encryption-configuration '{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"aws:kms"}}]}'
  4. 4Share a file for one hour

    aws s3 presign s3://s0sta-lab-backups-2026/daily/backup.tar.gz --expires-in 3600
  5. 5List EC2 instances as a table

    aws ec2 describe-instances --query "Reservations[].Instances[].{id:InstanceId,state:State.Name,ip:PublicIpAddress,name:Tags[?Key=='Name']|[0].Value}" --output table
  6. 6Start and stop an instance

    aws ec2 stop-instances --instance-ids i-0abc123def4567890
    aws ec2 start-instances --instance-ids i-0abc123def4567890
  7. 7Find security groups open to the world

    aws ec2 describe-security-groups --query "SecurityGroups[?IpPermissions[?IpRanges[?CidrIp=='0.0.0.0/0']]].[GroupId,GroupName]" --output table
  8. 8Connect without SSH keys (Session Manager)

    aws ssm start-session --target i-0abc123def4567890
  9. 9Use an EKS cluster

    aws eks update-kubeconfig --name eks-lab --region eu-central-1
    kubectl get nodes
  10. 10Push an image to ECR

    aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.eu-central-1.amazonaws.com
    docker push 123456789012.dkr.ecr.eu-central-1.amazonaws.com/shop:1.4.0
  11. 11Read a secret

    aws secretsmanager get-secret-value --secret-id prod/db --query SecretString --output text
  12. 12Follow CloudWatch logs

    aws logs tail /aws/eks/eks-lab/cluster --follow --since 10m

Watch out

  • Never use root account keys; avoid long-lived access keys — use SSO or OIDC roles in CI.
  • aws s3 sync --delete deletes files in the target that are not in the source.

Files

~/.aws/config
Profiles, regions, SSO settings.
~/.aws/credentials
Access keys (avoid; keep private if used).

Tips to remember

Exit codes

0Success.
1Error in one or more S3 transfers.
2Command or argument error.
130Interrupted (Ctrl+C).
252Bad command syntax.
253Bad config or credentials.
254Service error (request failed).
255Other error.

Full manual

This page explains the command in simple words. The original manual has every detail.

In your terminal: man aws