SlideShare a Scribd company logo
©2015, Amazon Web Services, Inc. or its affiliates. All rights reserved
AWS Command Line Interface
Intro to the AWS CLI Exploring Key
Functionality
Looking at Advanced
CLI Features
Intro to the AWS CLI
AWS Command Line Interface
Unified tool to manage your AWS services
MSI (Windows)
Bundled (cross platform)
pip (cross platform)
aws configure
$ aws ec2 describe-instances
Service (command) Operation (subcommand)
$ aws iam list-access-keys
Service (command) Operation (subcommand)
{
"Places": [
{
"City": "Seattle",
"State": "WA"
},
{
"City": ”Las Vegas",
"State": "NV"
}
]
}
--output JSON
PLACES Seattle WA
PLACES Las Vegas NV
--output text
| SomeOperationName |
+ +
|| Places ||
|+- + +|
|| City | State ||
|+- + +|
|| Seattle | WA
|| Las Vegas | NV
||
||
|+- + +|
--output table
All Outputs
• JSON T
ext
PLACES
PLACES
Seattle WA
Las Vegas NV
T
able
| SomeOperationName |
+------------------------+
|| Places ||
|+------------+---------+|
|| City | State ||
|+------------+---------+|
|| Seattle | WA
|| Las Vegas | NV
||
||
|+------------+---------+|
{
"Places": [
{
"City": "Seattle",
"State": "WA"
},
{
"City": ”Las Vegas",
"State": "NV"
}
]
}
Demo
Basic AWS CLI Usage
Foundation
Exploring Key Functionality
Configuration
aws configure
aws configure
AWS access key ID [**ABCD]:
AWS secret access key [****************EFGH]:
Default region name [us-west-2]:
Default output format [None]:
aws configure <subcommand>
aws configure <subcommand>
list - list common configuration sources
get - get the value of a single config var
set - set the value of a single config var
aws configure get region
aws configure set profile.prod.region us-west-2
A profile is a group of configuration values
aws configure --profile prod
Configuration Files
~/.aws/credentials ~/.aws/config
• Supported by all AWS SDKs
• Only contains credentials
• Used only by the CLI
• Can contain credentials (but not
the default behavior)
~/.aws/credentials ~/.aws/config
aws configure set profile.prod.aws_access_key_id foo
~/.aws/credentials ~/.aws/config
aws configure set profile.prod.aws_access_key_id foo
~/.aws/credentials ~/.aws/config
[prod]
aws_access_key_id = foo
aws configure set profile.prod.aws_secret_access_key bar
~/.aws/credentials ~/.aws/config
[prod]
aws_access_key_id = foo
aws configure set profile.prod.aws_secret_access_key bar
~/.aws/credentials ~/.aws/config
[prod]
aws_access_key_id = foo
aws_secret_access_key = bar
aws configure set profile.prod.region uswest2
~/.aws/credentials ~/.aws/config
[prod]
aws_access_key_id = foo
aws_secret_access_key = bar
aws configure set profile.prod.region uswest2
~/.aws/credentials ~/.aws/config
[prod]
aws_access_key_id = foo
aws_secret_access_key = bar
[profile prod]
region = us-west-2
aws configure set profile.prod.output text
~/.aws/credentials ~/.aws/config
[prod]
aws_access_key_id = foo
aws_secret_access_key = bar
[profile prod]
region = us-west-2
aws configure set profile.prod.output text
~/.aws/credentials ~/.aws/config
[prod]
aws_access_key_id = foo
aws_secret_access_key = bar
[profile prod]
region = us-west-2
output = text
create-new-user.sh
create-new-user.sh
create-new-user.sh
create-new-user.sh
create-new-user.sh
create-new-user.sh
Use the aws configure
suite of subcommands
Query
CLI.pptx
Implementation Details --query Processing
Implementation Details --query Processing
Implementation Details --query Processing
Implementation Details --query Processing
Implementation Details --query Processing
--query User[0].[UserName,Path,UserId]
Implementation Details --query Processing
--query User[0].[UserName,Path,UserId]
Implementation Details --query Processing
Implementation Details --query Processing
http://jmespath.org
A Query Language for JSON
Demo
JMESPATH
http://jmespath.org
A Query Language for JSON
Waiters
Amazon EC2 Instance State Transitions
ec2-instance-running.sh
#!/bin/bash
instance_id=$(aws ec2 run-instances –image-id ami-12345 
--query Reservations[].Instances[].InstanceId 
--output text)
instance_state=$(aws ec2 describe-instances –instance-ids $instance_id 
--query 'Reservations[].Instances[].State.Name')
while [ "$instance_state" != "running" ]
do
sleep 1
instance_state=$(aws ec2 describe-instances –instance-ids $instance_id 
--query 'Reservations[].Instances[].State.Name')
done
ec2-instance-running.sh
#!/bin/bash
instance_id=$(aws ec2 run-instances –image-id ami-12345 
--query Reservations[].Instances[].InstanceId 
--output text)
instance_state=$(aws ec2 describe-instances –instance-ids $instance_id 
--query 'Reservations[].Instances[].State.Name')
while [ "$instance_state" != "running" ]
do
sleep 1
instance_state=$(aws ec2 describe-instances –instance-ids $instance_id 
--query 'Reservations[].Instances[].State.Name')
done
ec2-instance-running.sh
#!/bin/bash
instance_id=$(aws ec2 run-instances –image-id ami-12345 
--query Reservations[].Instances[].InstanceId 
--output text)
instance_state=$(aws ec2 describe-instances –instance-ids $instance_id 
--query 'Reservations[].Instances[].State.Name')
while [ "$instance_state" != "running" ]
do
sleep 1
instance_state=$(aws ec2 describe-instances –instance-ids $instance_id 
--query 'Reservations[].Instances[].State.Name')
done
ec2-instance-running.sh
#!/bin/bash
instance_id=$(aws ec2 run-instances –image-id ami-12345 
--query Reservations[].Instances[].InstanceId 
--output text)
instance_state=$(aws ec2 describe-instances –instance-ids $instance_id 
--query 'Reservations[].Instances[].State.Name')
while [ "$instance_state" != "running" ]
do
sleep 1
instance_state=$(aws ec2 describe-instances –instance-ids $instance_id 
--query 'Reservations[].Instances[].State.Name')
done
ec2-instance-running.sh
#!/bin/bash
instance_id=$(aws ec2 run-instances –image-id ami-12345 
--query Reservations[].Instances[].InstanceId 
--output text)
instance_state=$(aws ec2 describe-instances –instance-ids $instance_id 
--query 'Reservations[].Instances[].State.Name')
while [ "$instance_state" != "running" ]
do
sleep 1
instance_state=$(aws ec2 describe-instances –instance-ids $instance_id 
--query 'Reservations[].Instances[].State.Name')
done
ec2-instance-running.sh
#!/bin/bash
instance_id=$(aws ec2 run-instances –image-id ami-12345 
--query Reservations[].Instances[].InstanceId 
--output text)
instance_state=$(aws ec2 describe-instances –instance-ids $instance_id 
--query 'Reservations[].Instances[].State.Name')
while [ "$instance_state" != "running" ]
do
sleep 1
instance_state=$(aws ec2 describe-instances –instance-ids $instance_id 
--query 'Reservations[].Instances[].State.Name')
done
ec2-waiters.sh
instance_id=$(aws ec2 run-instances –image-id ami-12345 
--query Reservations[].Instances[].InstanceId 
--output text)
aws ec2 wait instance-running –instance-ids $instance_id
ec2-waiters.sh
instance_id=$(aws ec2 run-instances –image-id ami-12345 
--query Reservations[].Instances[].InstanceId 
--output text)
aws ec2 wait instance-running –instance-ids $instance_id
subcommand
waiter name
Describe-instances options
Advanced Scenarios
Looking at advanced AWS CLI features
Templates
The AWS CLI is data driven
Implementation Details JSON Models
Implementation Details JSON Models
Implementation Details JSON Models
aws ec2 run‐instances –cli-input-json file://arguments.json
What else can we do?
aws ec2 run‐instances –generate-cli-skeleton
Demo
Creating and using JSON templates
Credential Providers
Credential Providers
Credential Providers
Credential Providers
Credential Providers
Credential Providers
Delegate access to AWS resources using
AWS Identity and Access Management (IAM) roles
IAM Roles
Production Development
IAM Roles
Production Development
IAM Roles
Production Development
Role
Policy
TrustvPolicy
role
IAM Roles
Production Development
AssumeRole
AWS Security
Token Service
role
IAM Roles
Production Development
AssumeRole
AWS Security
Token Service
role
token
IAM Roles
Production Development
AssumeRole
AWS Security
Token Service
role
token
aws configure set profile.prodrole.role_arn arn:aws:iam…
aws configure set profile.prodrole.source_profile dev
configure-role.sh
~/.aws/credentials ~/.aws/config
[profile prodrole]
role_arn = arn:aws:iam
source_profile = dev
~/.aws/credentials ~/.aws/config
[profile prodrole]
role_arn = arn:aws:iam
source_profile = dev
Demo
Using roles with the AWS CLI
Amazon S3 Streaming
aws s3 cp
We want to avoid disk
aws s3 cp – s3://bucket/key
aws s3 cp s3://bucket/key -
Compress

More Related Content

PDF
Masterclass Advanced Usage of the AWS CLI
KEY
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
PDF
Dutch PHP Conference - PHPSpec 2 - The only Design Tool you need
PDF
Casting for not so strange actors
KEY
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
PDF
JavaScript and the AST
KEY
Chef 0.8, Knife and Amazon EC2
PDF
PHPSpec - the only Design Tool you need - 4Developers
Masterclass Advanced Usage of the AWS CLI
Introduction to CloudForecast / YAPC::Asia 2010 Tokyo
Dutch PHP Conference - PHPSpec 2 - The only Design Tool you need
Casting for not so strange actors
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
JavaScript and the AST
Chef 0.8, Knife and Amazon EC2
PHPSpec - the only Design Tool you need - 4Developers

Similar to CLI.pptx (20)

PDF
Hacking ansible
PDF
Ansible Assume AWS Role
PDF
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
KEY
Backbone js
PPTX
Power shell voor developers
ODP
Integrating icinga2 and the HashiCorp suite
PDF
Burn down the silos! Helping dev and ops gel on high availability websites
PPTX
Puppet Camp Seattle 2014: Puppet: Cloud Infrastructure as Code
PDF
Puppet @ Seat
PDF
Unveiling the Future: Sylius 2.0 New Features
PDF
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
PDF
Simple Ways To Be A Better Programmer (OSCON 2007)
KEY
Refactor like a boss
PPT
PDF
Ben Bridts - $ aws help
PDF
Doing the Refactor Dance - Making Your Puppet Modules More Modular - PuppetCo...
PDF
Data Validation models
PDF
Bag Of Tricks From Iusethis
PDF
Amazon Web Services for PHP Developers
PPTX
AST - the only true tool for building JavaScript
Hacking ansible
Ansible Assume AWS Role
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Backbone js
Power shell voor developers
Integrating icinga2 and the HashiCorp suite
Burn down the silos! Helping dev and ops gel on high availability websites
Puppet Camp Seattle 2014: Puppet: Cloud Infrastructure as Code
Puppet @ Seat
Unveiling the Future: Sylius 2.0 New Features
Deployment and Management on AWS:
 A Deep Dive on Options and Tools
Simple Ways To Be A Better Programmer (OSCON 2007)
Refactor like a boss
Ben Bridts - $ aws help
Doing the Refactor Dance - Making Your Puppet Modules More Modular - PuppetCo...
Data Validation models
Bag Of Tricks From Iusethis
Amazon Web Services for PHP Developers
AST - the only true tool for building JavaScript
Ad

More from Ganesh Bhosale (20)

DOCX
3.AWR and ASH Reportsfor Oracle Tuning.docx
DOCX
Step by stepDoc for Oracle TuningsandAWR.docx
PPTX
2.Python_Testing_Using_PyUnit_PyTest.pptx
PPTX
1.Python_Testing_Using_PyUnit_Pytest.pptx
PPTX
2.Python_Unit _Testing_Using_PyUnit_Pytest.pptx
PPTX
awsfundamentals1_cloud_Infrastructure.pptx
PPTX
Generators-in-Python-for-Developers.pptx
PPTX
Advance-Python-Iterators-for-developers.pptx
PPTX
The ES Library for JavaScript Developers
PPTX
Git Repository for Developers working in Various Locations
PPTX
4.Problem Solving Techniques and Data Structures.pptx
PPTX
3.Problem Solving Techniques and Data Structures.pptx
PPTX
2.Problem Solving Techniques and Data Structures.pptx
PPTX
1. Problem Solving Techniques and Data Structures.pptx
PPTX
unittestinginpythonfor-PYDevelopers.pptx
PPTX
SQL-queries-for-Data-Analysts-Updated.pptx
PPTX
javascriptbasicsPresentationsforDevelopers
PPTX
Cloud-Architecture-Technology-Deovps-Eng
PDF
Backup-and-Recovery Procedures decribed in AWS
PPTX
KMSUnix and Linux.pptx
3.AWR and ASH Reportsfor Oracle Tuning.docx
Step by stepDoc for Oracle TuningsandAWR.docx
2.Python_Testing_Using_PyUnit_PyTest.pptx
1.Python_Testing_Using_PyUnit_Pytest.pptx
2.Python_Unit _Testing_Using_PyUnit_Pytest.pptx
awsfundamentals1_cloud_Infrastructure.pptx
Generators-in-Python-for-Developers.pptx
Advance-Python-Iterators-for-developers.pptx
The ES Library for JavaScript Developers
Git Repository for Developers working in Various Locations
4.Problem Solving Techniques and Data Structures.pptx
3.Problem Solving Techniques and Data Structures.pptx
2.Problem Solving Techniques and Data Structures.pptx
1. Problem Solving Techniques and Data Structures.pptx
unittestinginpythonfor-PYDevelopers.pptx
SQL-queries-for-Data-Analysts-Updated.pptx
javascriptbasicsPresentationsforDevelopers
Cloud-Architecture-Technology-Deovps-Eng
Backup-and-Recovery Procedures decribed in AWS
KMSUnix and Linux.pptx
Ad

Recently uploaded (20)

PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
PDF
Trump Administration's workforce development strategy
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
PPTX
Lesson notes of climatology university.
PDF
RMMM.pdf make it easy to upload and study
PPTX
Cell Types and Its function , kingdom of life
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
Hazard Identification & Risk Assessment .pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Complications of Minimal Access Surgery at WLH
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
Trump Administration's workforce development strategy
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
Chinmaya Tiranga quiz Grand Finale.pdf
UNIT III MENTAL HEALTH NURSING ASSESSMENT
A powerpoint presentation on the Revised K-10 Science Shaping Paper
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
Lesson notes of climatology university.
RMMM.pdf make it easy to upload and study
Cell Types and Its function , kingdom of life
Weekly quiz Compilation Jan -July 25.pdf
Hazard Identification & Risk Assessment .pdf
Final Presentation General Medicine 03-08-2024.pptx
History, Philosophy and sociology of education (1).pptx
Practical Manual AGRO-233 Principles and Practices of Natural Farming

CLI.pptx