Snelle referentie

AWS CLI Kerncommando's Spiekbrief

Kurzreferenz für AWS CLI: EC2-instantiebeheer, S3-bucket- en objectbeheer, benoemde profielen, ECS en Elastic Beanstalk.

· Gepubliceerd

Een beknopte handleiding voor veelvoorkomende beheertaken via de officiële AWS Command Line Interface (aws).

Installatie & Configuratie

# macOS (Homebrew)
brew install awscli

# Inloggegevens en standaardregio instellen
aws configure

# Benoemde profielen configureren
aws configure --profile staging
aws configure --profile production

Inloggegevens en configuraties worden opgeslagen in ~/.aws/credentials en ~/.aws/config.


Amazon S3 (Simple Storage Service)

# Buckets of inhoud van een bucket weergeven
aws s3 ls
aws s3 ls s3://my-bucket-name/prefix/

# Lokaal bestand naar S3 kopiëren
aws s3 cp document.pdf s3://my-bucket-name/docs/

# Lokale map synchroniseren met S3-bucket (met uitsluitingen)
aws s3 sync ./build s3://my-bucket-name/web --delete --exclude "*.tmp"

# Map of voorvoegsel recursief verwijderen
aws s3 rm s3://my-bucket-name/temporary-files --recursive

Amazon EC2 (Elastic Compute Cloud)

# Draaiende instanties beschrijven
aws ec2 describe-instances \
  --filters "Name=instance-state-name,Values=running" \
  --query "Reservations[*].Instances[*].[InstanceId,PublicIpAddress,Tags[?Key=='Name'].Value|[0]]" \
  --output table

# Instanties starten / stoppen
aws ec2 start-instances --instance-ids i-0123456789abcdef0
aws ec2 stop-instances --instance-ids i-0123456789abcdef0

# Instantie definitief beëindigen
aws ec2 terminate-instances --instance-ids i-0123456789abcdef0

Amazon ECS (Elastic Container Service)

# Clusters weergeven
aws ecs list-clusters

# Nieuw cluster aanmaken
aws ecs create-cluster --cluster-name production-cluster

# Actieve taken in cluster weergeven
aws ecs list-tasks --cluster production-cluster

AWS Elastic Beanstalk CLI (eb)

# Elastic Beanstalk-applicatie initialiseren
eb init

# Omgeving maken en applicatie implementeren
eb create production-env
eb deploy

# Applicatie openen in browser
eb open

# Realtime applicatielogboeken bekijken
eb logs

Handige vlaggen & zoekopdrachten

  • --profile <name>: Voer het commando uit onder een specifiek IAM-profiel.
  • --region <region>: Overschrijf de geconfigureerde AWS-regio.
  • --output [json|text|table]: Geef het uitvoerformaat op (json, text, table).
  • --query '<JMESPath>': Filter en extraheer gegevens met JMESPath-expressies.

Verwante onderwerpen