+ All Categories
Home > Software > Deep Dive into AWS CLI - the command line interface

Deep Dive into AWS CLI - the command line interface

Date post: 15-Aug-2015
Category:
Upload: john-varghese
View: 62 times
Download: 0 times
Share this document with a friend
23
aws cli Deep dive into the aws command line interface John Varghese – Devops Architect at Yuzu May 20, 2015
Transcript
Page 1: Deep Dive into AWS CLI - the command line interface

aws cli

Deep dive into the awscommand line interface

John Varghese – Devops Architect at YuzuMay 20, 2015

Page 2: Deep Dive into AWS CLI - the command line interface

Pro Tip

• When starting a presentation

– Turn off notifications– Quit iMessages– Quit your IM– Quit Outlook

Page 3: Deep Dive into AWS CLI - the command line interface

Who is using it today?

• Please raise you hand

Page 4: Deep Dive into AWS CLI - the command line interface

What is aws-cli?

• A unified tool • It provides a consistent interface for

interacting with all parts of AWS

Page 5: Deep Dive into AWS CLI - the command line interface

Installation

• Without brew (on *nix)– Install python 2.x.– Python 3.x will not work– wget, unzip, execute awscli-bundle.zip

• With homebrew– brew install awscli

Page 6: Deep Dive into AWS CLI - the command line interface

aws help

• Shows you the basic meta parameters that are independent of the actual service/command, or sub command.

• These meta parameters are also called options

Page 7: Deep Dive into AWS CLI - the command line interface

Command structure

aws [options] <command> <subcommand> [parameters]

Page 8: Deep Dive into AWS CLI - the command line interface

Some aws commands

• cloudformation• configure• ec2• elb• rds• route53

• cloudwatch• dynamodb• elasticache• redshift• s3api• And all the rest…

Page 9: Deep Dive into AWS CLI - the command line interface

Got oh-my-zsh?

Add the plugin (awscli)I just added it yesterday after all this

time. It is awesome!

Page 10: Deep Dive into AWS CLI - the command line interface

Auto-complete

Both bash and zsh have auto-complete for aws cli

Page 11: Deep Dive into AWS CLI - the command line interface

When you run into issues

Use the option --debug

Page 12: Deep Dive into AWS CLI - the command line interface

aws configure

~/.aws/config~/.aws/credentials

Page 13: Deep Dive into AWS CLI - the command line interface

AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY

Use these Environment Variables to override the configuration settings.

There are a half dozen such variables.

Page 14: Deep Dive into AWS CLI - the command line interface

Output formats

• Json• Text• Table

• --output • Demo command– aws cloudformation list-

stack-resources --stack-name yuzu-es-dev-stack

Page 15: Deep Dive into AWS CLI - the command line interface

Parameters via json

• aws cloudformation list-stack-resources --stack-name yuzu-es-dev-stack --generate-cli-skeleton

• aws cloudformation list-stack-resources --cli-input-json file://x.json

Page 16: Deep Dive into AWS CLI - the command line interface

--dry-runJust validate the command

Also --no-dry-run Default behaviour

Page 17: Deep Dive into AWS CLI - the command line interface

describe-regions with --dry-run

aws ec2 describe-regions --generate-cli-skeleton > x.json

aws ec2 describe-regions --cli-input-json file://x.json

A contrived example

Page 18: Deep Dive into AWS CLI - the command line interface

JMESpath

• A short diversion• Visit JMESpath.org

• Iteration• [0]• [*]• []• ?

• Demo – python syntax– Try out some of the

examples on the tutorial

Page 19: Deep Dive into AWS CLI - the command line interface

--query

Use this to filter the results.

Demo commands on following slides

Page 20: Deep Dive into AWS CLI - the command line interface

Filtering the results

• aws ec2 describe-volumes– Leverage head -10

• aws ec2 describe-volumes --query 'Volumes[0]’

• aws ec2 describe-volumes --query 'Volumes[*].{ID:VolumeId,AZ:AvailabilityZone,Size:Size}'

Page 21: Deep Dive into AWS CLI - the command line interface

Filtering results some more

• Chained keys such as key1.key2[0].key3

• Attachments[0].InstanceId

• aws ec2 describe-volumes --query 'Volumes[*].{ID:VolumeId,InstanceId:Attachments[0].InstanceId,AZ:AvailabilityZone,Size:Size}’

Page 22: Deep Dive into AWS CLI - the command line interface

Filtering multiple elements

• Use the list notation: [key1, key2]

• aws ec2 describe-volumes --query 'Volumes[*].[VolumeId, Attachments[0].InstanceId, AvailabilityZone, Size]'

Page 23: Deep Dive into AWS CLI - the command line interface

Filter by value of a field

• Use the JMESPath "?" operator

• Note the backticks

• aws ec2 describe-volumes --query 'Volumes[?AvailabilityZone==`us-east-1d`]'


Recommended