Difference between revisions of "AWS/CLI"

From Ever changing code
< AWS
Jump to navigation Jump to search
Line 7: Line 7:


= Configure AWS credentials =
= Configure AWS credentials =
Create default profile in ~/.aws/credentials file and ~/.aws/config file
Create default profile in ~/.aws/credentials file and ~/.aws/config file, the values are processed in this order.
  aws configure
  aws configure
  aws ec2 describe-regions  #to get a list all available regions
  aws ec2 describe-regions  #to get a list all available regions
Line 13: Line 13:
The <tt>/.aws/config</tt> profile sections must have the format of <tt>'''[profile profile-name]'''</tt>, except for the default profile. For example:
The <tt>/.aws/config</tt> profile sections must have the format of <tt>'''[profile profile-name]'''</tt>, except for the default profile. For example:


  # Example ~/.aws/config file.
  # Example ~/.aws/config file
  [default]
  [default]
  aws_access_key_id=foo
  aws_access_key_id=***
  aws_secret_access_key=bar
  aws_secret_access_key=***
   
   
  [profile dev]
  [profile dev]
  aws_access_key_id=foo2
  aws_access_key_id=***
  aws_secret_access_key=bar2
  aws_secret_access_key=***


= Examples =
= Examples =

Revision as of 13:19, 12 August 2017

Install AWS cli (command line)

curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py
pip install awscli

or

sudo apt-get install awscli  #it will update a lot of packages to Python3 but will leave 2.7 as default

Configure AWS credentials

Create default profile in ~/.aws/credentials file and ~/.aws/config file, the values are processed in this order.

aws configure
aws ec2 describe-regions  #to get a list all available regions

The /.aws/config profile sections must have the format of [profile profile-name], except for the default profile. For example:

# Example ~/.aws/config file
[default]
aws_access_key_id=***
aws_secret_access_key=***

[profile dev]
aws_access_key_id=***
aws_secret_access_key=***

Examples

Create a reusable delegation set with a unique string '20170409'

aws route53 create-reusable-delegation-set --caller-reference 20170409

List the reusable-delegation-set created in ~/.aws/credentials profile

aws route53 list-reusable-delegation-sets --profile terraform-profile

List IAM server certificates, delete a certificate

aws iam list-server-certificates | grep ServerCertificateName
aws iam delete-server-certificate --server-certificate-name <cert_name>

References