Más contenido relacionado La actualidad más candente (20) Similar a AWS re:Invent 2016: The Effective AWS CLI User (DEV402) (20) Más de Amazon Web Services (20) AWS re:Invent 2016: The Effective AWS CLI User (DEV402)1. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Kyle Knapp, Amazon Web Services
December 1, 2016
DEV402
The Effective AWS CLI User
3. Background Material
• AWS CLI User Guide
• AWS CLI Command Reference
• 2015 AWS CLI re:Invent talk
• 2014 AWS CLI re:Invent talk
• 2013 AWS CLI re:Invent talk
4. Background Material
• AWS CLI User Guide
• AWS CLI Command Reference
• 2015 AWS CLI re:Invent talk
• 2014 AWS CLI re:Invent talk
• 2013 AWS CLI re:Invent talk
Slides will be online!
7. The Effective AWS CLI User Tenets
The effective AWS CLI user:
Uses an iterative workflow
8. The Effective AWS CLI User Tenets
The effective AWS CLI user:
Uses an iterative workflow
Troubleshoots well
9. The Effective AWS CLI User Tenets
The effective AWS CLI user:
Uses an iterative workflow
Troubleshoots well
Is resourceful with tooling
10. The Effective AWS CLI User Tenets
The effective AWS CLI user:
Uses an iterative workflow
Troubleshoots well
Is resourceful with tooling
Understands performance implications
23. The Effective AWS CLI User Tenets
The effective AWS CLI user:
Uses an iterative workflow
24. $ aws ec2 create-vpc --cidr-block 10.0.0.0/16
25. $ aws ec2 create-vpc --cidr-block 10.0.0.0/16
{
"Vpc": {
"VpcId": "vpc-24de2d4d",
"InstanceTenancy": "default",
"State": "pending",
"DhcpOptionsId": "dopt-f8ca2291",
"CidrBlock": "10.0.0.0/16",
"IsDefault": false
}
}
26. $ aws ec2 create-vpc --cidr-block 10.0.0.0/16
{
"Vpc": {
"VpcId": "vpc-24de2d4d",
"InstanceTenancy": "default",
"State": "pending",
"DhcpOptionsId": "dopt-f8ca2291",
"CidrBlock": "10.0.0.0/16",
"IsDefault": false
}
}
27. $ aws ec2 create-vpc --cidr-block 10.0.0.0/16
{
"Vpc": {
"VpcId": "vpc-24de2d4d",
"InstanceTenancy": "default",
"State": "pending",
"DhcpOptionsId": "dopt-f8ca2291",
"CidrBlock": "10.0.0.0/16",
"IsDefault": false
}
}
$ vpc_id=vpc-24de2d4d
28. $ aws ec2 create-vpc --cidr-block 10.0.0.0/16
{
"Vpc": {
"VpcId": "vpc-24de2d4d",
"InstanceTenancy": "default",
"State": "pending",
"DhcpOptionsId": "dopt-f8ca2291",
"CidrBlock": "10.0.0.0/16",
"IsDefault": false
}
}
$ vpc_id=vpc-24de2d4d
We can do better…
29. $ vpc_id=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16
--query Vpc.VpcId --output text)
30. $ vpc_id=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16
--query Vpc.VpcId --output text)
{
"Vpc": {
"VpcId": "vpc-24de2d4d",
"InstanceTenancy": "default",
"State": "pending",
"DhcpOptionsId": "dopt-f8ca2291",
"CidrBlock": "10.0.0.0/16",
"IsDefault": false
}
}
31. $ vpc_id=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16
--query Vpc.VpcId --output text)
{
"Vpc": {
"VpcId": "vpc-24de2d4d",
"InstanceTenancy": "default",
"State": "pending",
"DhcpOptionsId": "dopt-f8ca2291",
"CidrBlock": "10.0.0.0/16",
"IsDefault": false
}
}
32. $ vpc_id=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16
--query Vpc.VpcId --output text)
{
"Vpc": {
"VpcId": "vpc-24de2d4d",
"InstanceTenancy": "default",
"State": "pending",
"DhcpOptionsId": "dopt-f8ca2291",
"CidrBlock": "10.0.0.0/16",
"IsDefault": false
}
}
33. $ vpc_id=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16
--query Vpc.VpcId --output text)
{
"Vpc": {
"VpcId": "vpc-24de2d4d",
"InstanceTenancy": "default",
"State": "pending",
"DhcpOptionsId": "dopt-f8ca2291",
"CidrBlock": "10.0.0.0/16",
"IsDefault": false
}
}
34. $ vpc_id=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16
--query Vpc.VpcId --output text)
{
"Vpc": {
"VpcId": "vpc-24de2d4d",
"InstanceTenancy": "default",
"State": "pending",
"DhcpOptionsId": "dopt-f8ca2291",
"CidrBlock": "10.0.0.0/16",
"IsDefault": false
}
}
35. $ vpc_id=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16
--query Vpc.VpcId --output text)
$ echo "$vpc_id”
vpc-24de2d4d
36. $ vpc_id=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16
--query Vpc.VpcId --output text)
$ echo "$vpc_id"
vpc-24de2d4d
$ create_vpc_output=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16)
37. $ vpc_id=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16
--query Vpc.VpcId --output text)
$ echo "$vpc_id"
vpc-24de2d4d
$ create_vpc_output=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16)
$ vpc_id=$(jp -u Vpc.VpcId <<< "$create_vpc_output“)
38. $ vpc_id=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16
--query Vpc.VpcId --output text)
$ echo "$vpc_id"
vpc-24de2d4d
$ create_vpc_output=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16)
$ vpc_id=$(jp -u Vpc.VpcId <<< "$create_vpc_output")
$ echo "$vpc_id"
vpc-24de2d4d
39. $ vpc_id=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16
--query Vpc.VpcId --output text)
$ echo "$vpc_id"
vpc-24de2d4d
$ create_vpc_output=$(aws ec2 create-vpc --cidr-block 10.0.0.0/16)
$ vpc_id=$(jp -u Vpc.VpcId <<< "$create_vpc_output")
$ echo "$vpc_id"
vpc-24de2d4d
And we can make this even better!
43. $ aws ec2 create-vpc --cidr-block 10.0.0.0/16 --generate-cli-skeleton output
{
"Vpc": {
"VpcId": "VpcId",
"State": "State",
"CidrBlock": "CidrBlock",
"DhcpOptionsId": "DhcpOptionsId",
"Tags": [
{
"Key": "Key",
"Value": "Value"
}
],
"InstanceTenancy": "InstanceTenancy",
"IsDefault": true
}
}
44. $ aws ec2 create-vpc --cidr-block 10.0.0.0/16 --generate-cli-skeleton output
{
"Vpc": {
"VpcId": "VpcId",
"State": "State",
"CidrBlock": "CidrBlock",
"DhcpOptionsId": "DhcpOptionsId",
"Tags": [
{
"Key": "Key",
"Value": "Value"
}
],
"InstanceTenancy": "InstanceTenancy",
"IsDefault": true
}
}
"Vpc":{
"type":"structure",
"members":{
"VpcId":{
"shape":"String"
},
"State":{
"shape":"VpcState"
},
"CidrBlock":{
"shape":"String"
},
"DhcpOptionsId":{
"shape":"String"
},
"Tags":{
"shape":"TagList"
},
"InstanceTenancy":{
"shape":"Tenancy"
},
"IsDefault":{
"shape":"Boolean"
}
}
} botocore/botocore/data/ec2/2016-09-15/service-2.json
45. $ aws ec2 create-vpc --cidr-block 10.0.0.0/16 --generate-cli-skeleton output
{
"Vpc": {
"VpcId": "VpcId",
"State": "State",
"CidrBlock": "CidrBlock",
"DhcpOptionsId": "DhcpOptionsId",
"Tags": [
{
"Key": "Key",
"Value": "Value"
}
],
"InstanceTenancy": "InstanceTenancy",
"IsDefault": true
}
}
"Vpc":{
"type":"structure",
"members":{
"VpcId":{
"shape":"String"
},
"State":{
"shape":"VpcState"
},
"CidrBlock":{
"shape":"String"
},
"DhcpOptionsId":{
"shape":"String"
},
"Tags":{
"shape":"TagList"
},
"InstanceTenancy":{
"shape":"Tenancy"
},
"IsDefault":{
"shape":"Boolean"
}
}
} botocore/botocore/data/ec2/2016-09-15/service-2.json
46. $ aws ec2 create-vpc --cidr-block 10.0.0.0/16 --generate-cli-skeleton output
{
"Vpc": {
"VpcId": "VpcId",
"State": "State",
"CidrBlock": "CidrBlock",
"DhcpOptionsId": "DhcpOptionsId",
"Tags": [
{
"Key": "Key",
"Value": "Value"
}
],
"InstanceTenancy": "InstanceTenancy",
"IsDefault": true
}
}
"Vpc":{
"type":"structure",
"members":{
"VpcId":{
"shape":"String"
},
"State":{
"shape":"VpcState"
},
"CidrBlock":{
"shape":"String"
},
"DhcpOptionsId":{
"shape":"String"
},
"Tags":{
"shape":"TagList"
},
"InstanceTenancy":{
"shape":"Tenancy"
},
"IsDefault":{
"shape":"Boolean"
}
}
} botocore/botocore/data/ec2/2016-09-15/service-2.json
47. $ aws ec2 create-vpc --cidr-block 10.0.0.0/16 --generate-cli-skeleton output
{
"Vpc": {
"VpcId": "VpcId",
"State": "State",
"CidrBlock": "CidrBlock",
"DhcpOptionsId": "DhcpOptionsId",
"Tags": [
{
"Key": "Key",
"Value": "Value"
}
],
"InstanceTenancy": "InstanceTenancy",
"IsDefault": true
}
}
"Vpc":{
"type":"structure",
"members":{
"VpcId":{
"shape":"String"
},
"State":{
"shape":"VpcState"
},
"CidrBlock":{
"shape":"String"
},
"DhcpOptionsId":{
"shape":"String"
},
"Tags":{
"shape":"TagList"
},
"InstanceTenancy":{
"shape":"Tenancy"
},
"IsDefault":{
"shape":"Boolean"
}
}
} botocore/botocore/data/ec2/2016-09-15/service-2.json
52. The Effective AWS CLI User Tenets
The effective AWS CLI user:
Troubleshoots well
53. $ aws ec2 create-security-group --group-name re:Invent
--vpc-id VpcId
54. $ aws ec2 create-security-group --group-name re:Invent
--vpc-id VpcId
aws: error: argument --description is required
55. $ aws ec2 create-security-group --group-name re:Invent
--vpc-id VpcId
aws: error: argument --description is required
$ aws ec2 create-security-group --group-name re:Invent
--description 're:Invent demo' --vpc-id VpcId
56. $ aws ec2 create-security-group --group-name re:Invent
--vpc-id VpcId
aws: error: argument --description is required
$ aws ec2 create-security-group --group-name re:Invent
--description 're:Invent demo' --vpc-id VpcId
An error occurred (InvalidVpcID.NotFound) when calling the
CreateSecurityGroup operation: The vpc ID 'VpcId' does not exist
58. $ aws ec2 create-security-group --group-name re:Invent
--description 're:Invent demo' --vpc-id "$vpc_id” --debug
59. $ aws ec2 create-security-group --group-name re:Invent
--description 're:Invent demo' --vpc-id "$vpc_id” --debug
60. $ aws ec2 create-security-group --group-name re:Invent
--description 're:Invent demo' --vpc-id "$vpc_id" -–debug
2016-11-04 10:30:33,532 - MainThread - awscli.clidriver - DEBUG - CLI version: aws-
cli/1.11.10 Python/2.7.10 Darwin/15.6.0 botocore/1.4.65
2016-11-04 10:30:33,533 - MainThread - awscli.clidriver - DEBUG - Arguments entered to
CLI: ['ec2', 'create-security-group', '--group-name', 're:Invent', '--description',
're:Invent demo', '--vpc-id', 'vpc-43cb382a', '--debug']
2016-11-04 10:30:33,533 - MainThread - botocore.hooks - DEBUG - Event session-
initialized: calling handler <function add_scalar_parsers at 0x10eefc488>
2016-11-04 10:30:33,533 - MainThread - botocore.hooks - DEBUG - Event session-
initialized: calling handler <function inject_assume_role_provider_cache at
0x10ecde578>
2016-11-04 10:30:33,533 - MainThread - botocore.credentials - DEBUG - Skipping
environment variable credential check because profile name was explicitly set.
2016-11-04 10:30:33,537 - MainThread - botocore.loaders - DEBUG - Loading JSON file:
/Users/kyleknap/GitHub/botocore/botocore/data/ec2/2016-09-15/service-2.json
2016-11-04 10:30:33,622 - MainThread - botocore.hooks - DEBUG - Event service-data-
loaded.ec2: calling handler <function register_retries_for_service at 0x10e904500>
61. 2016-11-04 10:30:33,623 - MainThread - botocore.handlers - DEBUG - Registering retry
handlers for service: ec2
2016-11-04 10:30:33,628 - MainThread - botocore.hooks - DEBUG - Event building-command-
table.ec2: calling handler <functools.partial object at 0x10ef02940>
2016-11-04 10:30:33,628 - MainThread - awscli.customizations.removals - DEBUG -
Removing operation: import-instance
2016-11-04 10:30:33,628 - MainThread - awscli.customizations.removals - DEBUG -
Removing operation: import-volume
2016-11-04 10:30:33,628 - MainThread - botocore.hooks - DEBUG - Event building-command-
table.ec2: calling handler <function add_waiters at 0x10ef03578>
2016-11-04 10:30:33,631 - MainThread - botocore.loaders - DEBUG - Loading JSON file:
/Users/kyleknap/GitHub/botocore/botocore/data/ec2/2016-09-15/waiters-2.json
2016-11-04 10:30:33,635 - MainThread - awscli.clidriver - DEBUG - OrderedDict([(u'dry-
run', <awscli.arguments.BooleanArgument object at 0x10febe950>), (u'no-dry-run',
<awscli.arguments.BooleanArgument object at 0x10febe990>), (u'group-name',
<awscli.arguments.CLIArgument object at 0x10febe9d0>), (u'description',
<awscli.arguments.CLIArgument object at 0x10febea10>), (u'vpc-id',
<awscli.arguments.CLIArgument object at 0x10febea50>)])
62. 2016-11-04 10:30:33,623 - MainThread - botocore.handlers - DEBUG - Registering retry
handlers for service: ec2
2016-11-04 10:30:33,628 - MainThread - botocore.hooks - DEBUG - Event building-command-
table.ec2: calling handler <functools.partial object at 0x10ef02940>
2016-11-04 10:30:33,628 - MainThread - awscli.customizations.removals - DEBUG -
Removing operation: import-instance
2016-11-04 10:30:33,628 - MainThread - awscli.customizations.removals - DEBUG -
Removing operation: import-volume
2016-11-04 10:30:33,628 - MainThread - botocore.hooks - DEBUG - Event building-command-
table.ec2: calling handler <function add_waiters at 0x10ef03578>
2016-11-04 10:30:33,631 - MainThread - botocore.loaders - DEBUG - Loading JSON file:
/Users/kyleknap/GitHub/botocore/botocore/data/ec2/2016-09-15/waiters-2.json
2016-11-04 10:30:33,635 - MainThread - awscli.clidriver - DEBUG - OrderedDict([(u'dry-
run', <awscli.arguments.BooleanArgument object at 0x10febe950>), (u'no-dry-run',
<awscli.arguments.BooleanArgument object at 0x10febe990>), (u'group-name',
<awscli.arguments.CLIArgument object at 0x10febe9d0>), (u'description',
<awscli.arguments.CLIArgument object at 0x10febea10>), (u'vpc-id',
<awscli.arguments.CLIArgument object at 0x10febea50>)])
And this continues on for a while…
63. Parse command
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id vpc-24de2d4d
--query GroupId --output text
64. Parse command
botocore client call
# Python code
response = ec2_client.create_security_group(
GroupName=‘re:Invent’,
Description=‘re:Invent demo’,
VpcId=‘vpc-24de2d4d’
)
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id vpc-24de2d4d
--query GroupId --output text
65. Parse command
botocore client call
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id vpc-24de2d4d
--query GroupId --output text
# Python code
response = ec2_client.create_security_group(
GroupName=‘re:Invent’,
Description=‘re:Invent demo’,
VpcId=‘vpc-24de2d4d’
)
66. Parse command
botocore client call
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id vpc-24de2d4d
--query GroupId --output text
# Python code
response = ec2_client.create_security_group(
GroupName=‘re:Invent’,
Description=‘re:Invent demo’,
VpcId=‘vpc-24de2d4d’
)
67. Parse command
Format response
botocore client call
sg-1d032e64
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id vpc-24de2d4d
--query GroupId --output text
# Python code
response = ec2_client.create_security_group(
GroupName=‘re:Invent’,
Description=‘re:Invent demo’,
VpcId=‘vpc-24de2d4d’
)
68. Parse command
Format response
botocore client call
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id vpc-24de2d4d
--query GroupId --output text
# Python code
response = ec2_client.create_security_group(
GroupName=‘re:Invent’,
Description=‘re:Invent demo’,
VpcId=‘vpc-24de2d4d’
)
sg-1d032e64
69. Parse command
Format response
botocore client call
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id vpc-24de2d4d
--query GroupId --output text
# Python code
response = ec2_client.create_security_group(
GroupName=‘re:Invent’,
Description=‘re:Invent demo’,
VpcId=‘vpc-24de2d4d’
)
sg-1d032e64
71. Parse command
Format response
botocore client call
Validate/Serialize parameters
"CreateSecurityGroupRequest”{
"type":"structure”,
"required":["GroupName", "Description”],
"members":{
"DryRun":{
"shape":"Boolean”
},
"GroupName":{
"shape":"String”
},
"Description":{
"shape":"String”
},
"VpcId":{
"shape":"String”
}
}
}
botocore/botocore/data/ec2/2016-09-15/service-2.json
73. Parse command
Format response
Make botocore client call
Validate/Serialize parameters
HTTP request/response
Parse response
"CreateSecurityGroupResult”:{
"type":"structure”,
"members":{
"GroupId":{
"shape":"String”
}
}
} botocore/botocore/data/ec2/2016-09-15/service-2.json
76. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
awscli.clidriver - DEBUG - Arguments
entered to CLI: ['ec2', 'create-security-
group', '--group-name', 're:Invent’,
'--description', 're:Invent demo’,
'--vpc-id', 'vpc-43cb382a', '--debug']
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id "$vpc_id" -–debug
77. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
awscli.clidriver - DEBUG - Arguments
entered to CLI: ['ec2', 'create-security-
group', '--group-name', 're:Invent’,
'--description', 're:Invent demo’,
'--vpc-id', 'vpc-43cb382a', '--debug']
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id "$vpc_id" -–debug
78. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
awscli.clidriver - DEBUG - Arguments
entered to CLI: ['ec2', 'create-security-
group', '--group-name', 're:Invent’,
'--description', 're:Invent demo’,
'--vpc-id', 'vpc-43cb382a', '--debug']
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id "$vpc_id" -–debug
81. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
$ aws ec2 create-security-group
--group-name re:Invent
--description file://description.txt
--vpc-id "$vpc_id" -–debug
awscli.clidriver - DEBUG - Arguments
entered to CLI: ['ec2', 'create-security-
group', '--group-name', 're:Invent’,
'--description', 'file://description.txt’,
'--vpc-id', 'vpc-43cb382a', '--debug']
82. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
$ aws ec2 create-security-group
--group-name re:Invent
--description file://description.txt
--vpc-id "$vpc_id" -–debug
awscli.clidriver - DEBUG - Arguments
entered to CLI: ['ec2', 'create-security-
group', '--group-name', 're:Invent’,
'--description', 'file://description.txt’,
'--vpc-id', 'vpc-43cb382a', '--debug']
83. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
awscli.arguments - DEBUG - Unpacked value
of u're:Invent demo' for parameter
"description": u're:Invent demo'
$ aws ec2 create-security-group
--group-name re:Invent
--description file://description.txt
--vpc-id "$vpc_id" -–debug
awscli.clidriver - DEBUG - Arguments
entered to CLI: ['ec2', 'create-security-
group', '--group-name', 're:Invent’,
'--description', 'file://description.txt’,
'--vpc-id', 'vpc-43cb382a', '--debug']
84. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
awscli.arguments - DEBUG - Unpacked value
of u're:Invent demo' for parameter
"description": u're:Invent demo'
$ aws ec2 create-security-group
--group-name re:Invent
--description file://description.txt
--vpc-id "$vpc_id" -–debug
awscli.clidriver - DEBUG - Arguments
entered to CLI: ['ec2', 'create-security-
group', '--group-name', 're:Invent’,
'--description', 'file://description.txt’,
'--vpc-id', 'vpc-43cb382a', '--debug']
86. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id "$vpc_id" -–debug
botocore.endpoint - DEBUG - Making request for
OperationModel(name=CreateSecurityGroup)
(verify_ssl=True) with params: {
'body': {
'Action': 'CreateSecurityGroup',
'GroupName': 're:Invent’,
'Version': '2016-09-15’,
'VpcId': 'vpc-43cb382a',
‘GroupDescription': 're:Invent demo’
},
‘url':'https://ec2.us-east-2.amazonaws.com/’,
...
}
87. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id "$vpc_id" -–debug
botocore.endpoint - DEBUG - Making request for
OperationModel(name=CreateSecurityGroup)
(verify_ssl=True) with params: {
'body': {
'Action': 'CreateSecurityGroup',
'GroupName': 're:Invent’,
'Version': '2016-09-15’,
'VpcId': 'vpc-43cb382a',
‘GroupDescription': 're:Invent demo’
},
‘url':'https://ec2.us-east-2.amazonaws.com/’,
...
}
88. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id "$vpc_id" -–debug
botocore.endpoint - DEBUG - Making request for
OperationModel(name=CreateSecurityGroup)
(verify_ssl=True) with params: {
'body': {
'Action': 'CreateSecurityGroup',
'GroupName': 're:Invent’,
'Version': '2016-09-15’,
'VpcId': 'vpc-43cb382a',
‘GroupDescription': 're:Invent demo’
},
‘url':'https://ec2.us-east-2.amazonaws.com/’,
...
}
89. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id "$vpc_id" -–debug
botocore.endpoint - DEBUG - Making request for
OperationModel(name=CreateSecurityGroup)
(verify_ssl=True) with params: {
'body': {
'Action': 'CreateSecurityGroup',
'GroupName': 're:Invent’,
'Version': '2016-09-15’,
'VpcId': 'vpc-43cb382a',
‘GroupDescription': 're:Invent demo’
},
‘url':'https://ec2.us-east-2.amazonaws.com/’,
...
}
90. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id "$vpc_id" -–debug
botocore.vendored.requests.packages.urllib3
.connectionpool - DEBUG - "POST / HTTP/1.1"
200 None
91. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id "$vpc_id" -–debug
botocore.vendored.requests.packages.urllib3
.connectionpool - DEBUG - "POST / HTTP/1.1"
200 None
92. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id "$vpc_id" -–debug
botocore.parsers - DEBUG - Response body:
<?xml version="1.0" encoding="UTF-8"?>
<CreateSecurityGroupResponse>
<requestId>request-id</requestId>
<return>true</return>
<groupId>sg-5ec80f37</groupId>
</CreateSecurityGroupResponse>
93. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id "$vpc_id" -–debug
botocore.parsers - DEBUG - Response body:
<?xml version="1.0" encoding="UTF-8"?>
<CreateSecurityGroupResponse>
<requestId>request-id</requestId>
<return>true</return>
<groupId>sg-5ec80f37</groupId>
</CreateSecurityGroupResponse>
94. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id "$vpc_id" -–debug
botocore.parsers - DEBUG - Response body:
<?xml version="1.0" encoding="UTF-8"?>
<CreateSecurityGroupResponse>
<requestId>request-id</requestId>
<return>true</return>
<groupId>sg-5ec80f37</groupId>
</CreateSecurityGroupResponse>
95. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id "$vpc_id" -–debug
botocore.retryhandler - DEBUG - No retry
needed.
botocore.parsers - DEBUG - Response body:
<?xml version="1.0" encoding="UTF-8"?>
<CreateSecurityGroupResponse>
<requestId>request-id</requestId>
<return>true</return>
<groupId>sg-5ec80f37</groupId>
</CreateSecurityGroupResponse>
96. Parse command
Format response
Validate/Serialize parameters
HTTP request/response
Parse response
$ aws ec2 create-security-group
--group-name re:Invent
--description 're:Invent demo'
--vpc-id "$vpc_id" -–debug
botocore.retryhandler - DEBUG - No retry
needed.
botocore.parsers - DEBUG - Response body:
<?xml version="1.0" encoding="UTF-8"?>
<CreateSecurityGroupResponse>
<requestId>request-id</requestId>
<return>true</return>
<groupId>sg-5ec80f37</groupId>
</CreateSecurityGroupResponse>
101. The Effective AWS CLI User Tenets
The effective AWS CLI user:
Is resourceful with tooling
104. • BASH: variables, pipes, functions
• UNIX commands: xargs, sort, tail
• External tools: jp, jpterm, aws-shell
105. • BASH: variables, pipes, functions
• UNIX commands: xargs, sort, tail
• External tools: jp, jpterm, aws-shell
• DIY (Do it yourself) tooling
110. [alias]
st = status
ci = commit
br = branch
co = checkout
~/.gitconfig
$ git co some-branch $ git checkout some-branch
115. The Effective AWS CLI User Tenets
The effective AWS CLI user:
Understands performance implications
118. $ aws ec2 describe-images
--query 'Images[?starts_with(to_string(Name),`amzn-ami-hvm-`)]'
119. $ aws ec2 describe-images
--query 'Images[?starts_with(to_string(Name),`amzn-ami-hvm-`)]'
120. $ aws ec2 describe-images
--query 'Images[?starts_with(to_string(Name),`amzn-ami-hvm-`)]'
121. $ aws ec2 describe-images
--query 'Images[?starts_with(to_string(Name),`amzn-ami-hvm-`)]'
$ aws ec2 describe-images
--filters Name=name,Values='amzn-ami-hvm-*' --query 'Images'
122. $ aws ec2 describe-images
--query 'Images[?starts_with(to_string(Name),`amzn-ami-hvm-`)]'
$ aws ec2 describe-images
--filters Name=name,Values='amzn-ami-hvm-*' --query 'Images'
123. $ aws ec2 describe-images
--query 'Images[?starts_with(to_string(Name),`amzn-ami-hvm-`)]'
$ aws ec2 describe-images
--filters Name=name,Values='amzn-ami-hvm-*' --query 'Images'
126. $ aws ec2 describe-snapshots
{
"Snapshots”: [
{
"SnapshotId": "snap-0",
...
},
...
]
} }
127. $ aws ec2 describe-snapshots
{
"Snapshots”: [
{
"SnapshotId": "snap-0",
...
},
...
]
} }
{
"Snapshots”: [
{
"SnapshotId": "snap-1000",
...
},
...
]
} }
128. $ aws ec2 describe-snapshots
{
"Snapshots”: [
{
"SnapshotId": "snap-0",
...
},
...
]
} }
{
"Snapshots”: [
{
"SnapshotId": "snap-1000",
...
},
...
]
} }
{
"Snapshots”: [
{
"SnapshotId": "snap-2000",
...
},
...
]
} }
129. $ aws ec2 describe-snapshots
{
"Snapshots”: [
{
"SnapshotId": "snap-0",
...
},
...
]
} }
{
"Snapshots”: [
{
"SnapshotId": "snap-1000",
...
},
...
]
} }
{
"Snapshots”: [
{
"SnapshotId": "snap-2000",
...
},
...
]
} }
{
"Snapshots”: [
{
"SnapshotId": "snap-0",
...
},
...
{
"SnapshotId": "snap-1000",
...
},
...
{
"SnapshotId": "snap-2000",
...
},
...
]
} }
130. $ aws ec2 describe-snapshots --output text --query 'Snapshots[].SnapshotId'
{
"Snapshots”: [
{
"SnapshotId": "snap-0",
...
},
...
]
} }
{
"Snapshots”: [
{
"SnapshotId": "snap-1000",
...
},
...
]
} }
{
"Snapshots”: [
{
"SnapshotId": "snap-2000",
...
},
...
]
} }
131. $ aws ec2 describe-snapshots --output text --query 'Snapshots[].SnapshotId'
{
"Snapshots”: [
{
"SnapshotId": "snap-0",
...
},
...
]
} }
{
"Snapshots”: [
{
"SnapshotId": "snap-1000",
...
},
...
]
} }
{
"Snapshots”: [
{
"SnapshotId": "snap-2000",
...
},
...
]
} }
132. {
"Snapshots”: [
{
"SnapshotId": "snap-0",
...
},
...
]
} }
{
"Snapshots”: [
{
"SnapshotId": "snap-1000",
...
},
...
]
} }
{
"Snapshots”: [
{
"SnapshotId": "snap-2000",
...
},
...
]
} }
$ aws ec2 describe-snapshots --output text --query 'Snapshots[].SnapshotId'
snap-0
...
snap-1000
...
snap-2000
...
}
142. [default]
region = us-east-1
s3 =
max_concurrent_requests = 20
multipart_chunksize = 16MB
multipart_threshold = 64MB
max_queue_size = 10000
~/.aws/config
143. [default]
region = us-east-1
s3 =
max_concurrent_requests = 20
multipart_chunksize = 16MB
multipart_threshold = 64MB
max_queue_size = 10000
~/.aws/config
148. Important Takeaways
• Use server-side filtering when
possible
• Pagination with --output text
• s3 configuration options
150. The Effective AWS CLI User Tenets
The effective AWS CLI user:
Uses an iterative workflow
Example: --generate-cli-skeleton output
151. The Effective AWS CLI User Tenets
The effective AWS CLI user:
Troubleshoots well
Example: --debug
152. The Effective AWS CLI User Tenets
The effective AWS CLI user:
Is resourceful with tooling
Example: alias
153. The Effective AWS CLI User Tenets
The effective AWS CLI user:
Understands performance implications
Example: s3 configurations