Skip to main content

AWS CLI Cheatsheet

Authentication

Log In Using Profile

aws sso login --profile dev

EC2

Stop EC2 Instance

aws ec2 stop-instances --instance-ids $EC2_INSTANCE

Stop EC2 Instance

aws ec2 start-instances --instance-ids $EC2_INSTANCE

Associate EC2 with IAM Role

aws ec2 associate-iam-instance-profile --instance-id "$EC2_INSTANCE" --iam-instance-profile Name="$AWS_IAM_ROLE_NAME"