pip install awscli
aws configure
ls ~/.aws
aws ec2 describe-instances
List instances using ssh key
aws ec2 describe-instances --query 'Reservations[*].Instances[?KeyName==`<sshKey>`].[InstanceId,KeyName,State.Name]' --output text
Create instance (amiId for Debian 12 eu-central-1 ami-0b1ceff20779a1adb)
aws ec2 run-instances --image-id <amiId> --count 1 --instance-type t2.micro --key-name <sshKey> --security-group-ids <groupId> --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=<name>},{Key=Project,Value=<project>}]'
aws ec2 terminate-instances --instance-ids "<instanceId>"
Get latest amiId of ubuntu
aws ssm get-parameters --names /aws/service/canonical/ubuntu/server/20.04/stable/current/amd64/hvm/ebs-gp2/ami-id
aws ec2 describe-security-groups
aws ec2 create-security-group --group-name <groupName> --description "<description>"
Add rule to security group
aws ec2 authorize-security-group-ingress --group-name <groupName> --protocol tcp --port <port> --cidr 0.0.0.0/0
aws ec2 describe-subnets --query 'Subnets[*].[SubnetId, AvailabilityZone, VpcId, Tags[?Key==`Name`].Value | [0]]'
Synchronize content of bucket
aws s3 sync s3://<name> <directory>
Download content of bucket
aws s3 cp ./<directory> s3://<name>/<path>
Get api gateways of region
aws apigateway --region eu-central-1 get-rest-apis
aws ec2 describe-key-pairs
aws ec2 import-key-pair --key-name "<name>" --public-key-material "<sshKey>"