Cheatsheet: AWS CLI

At the middle of 2010`s cloud infrastructure became necessity for software infrastructure. There is a huge trend to move a hardware maintenance from local datacenters to the cloud.

The most famous cloud infrastructure vendor is Amazon Web Services (AWS). We can talk about their benefits and shortcomings many hours in a row, but it’s not a subject here. Amazon provides a CLI interface for infrastructure and special services management. Choice of commands is really large. It allows to control your environment faster and make some processes automated. But it’s easy to confuse at this ocean of tools. For better productivity I would recommend to use a saws – your personal guidebook in AWS. But anyway we might get stuck at what does the each command of these stand for. Also there are plenty of customized flags helping to filter output or skip useless files to copy.

To struggle with “amazoned” disorder in my mind, I started to lead a new personal cheatsheet. Here I’ll add one command by one I mostly use in my AWS administration. You’re welcome to suggest any useful commands too in comments below.

Note: I’m starting each command with aws prefix to throw out any misunderstanding. Because when you’ll skip this keyword in your command – you’ll get nothing. Also I’m skipping commands from special EC2 CLI or some tools like this one. There is no big difference between these commands.

EC2

aws ec2 describeinstances Get full list of EC2 instances
aws ec2 create-tags –resources i-a1111111 –tags Key=Environment,Value=development Assign single tag for special EC2 instance
aws ec2 describe-tags –filters “Name=resource-id,Values=i-a1111111” Get tags list per special EC2 instance
aws ec2 run-instances –image-id ami-11111111 –key-name mykey –count 1 –instance-type t2.micro –subnet-id subnet-11111111 –security-group-ids sg-111111 Launch new EC2 instance
aws ec2 create-image –instance-id i-c2d76c07 –name “admin.dev.ticksa.com” Create new AMI image from existing EC2 instance
aws ec2 attach-volume  –volume-id vol-1d5cc8cc –instance-id i-dddddd70 –device /dev/sdh Attach volume to EC2 instance
aws ec2 modify-instance-attribute –instance-id i-44a44ac3 –instance-type “{\”Value\”: \”m1.small\”}” Change the class of stopped EC2 instance
aws ec2 modify-instance-attribute –instance-id i-44a44ac3 –disable-api-termination Enable instance termination protection

S3

aws s3 ls mybucket Simple S3 bucket content listing
aws s3api head-object –bucket mybucket –key myfile Get the full information of file located in S3

IAM

aws iam list-server-certificates Get SSL certificates list
Advertisements

One thought on “Cheatsheet: AWS CLI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s