Difference between revisions of "AWS CLI"

From NovaOrdis Knowledge Base
Jump to: navigation, search
(Configuration Profile)
(Installation)
(2 intermediate revisions by the same user not shown)
Line 18: Line 18:
  
 
{{External|https://docs.aws.amazon.com/cli/latest/userguide/awscli-install-bundle.html}}
 
{{External|https://docs.aws.amazon.com/cli/latest/userguide/awscli-install-bundle.html}}
 +
{{External|https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html}}
  
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
+
This article documents installation of AWS CLI v2.
+
unzip awscli-bundle.zip
+
+
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
+
  
Result (it should be already in PATH):
+
<syntaxhighlight lang='bash'>
 +
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
 +
sudo installer -pkg AWSCLIV2.pkg -target /
 +
</syntaxhighlight>
  
aws --version
+
Even it looks odd, "-target /" will install AWS CLI in /usr/local/aws-cli.
aws-cli/1.16.25 Python/2.7.10 Darwin/17.7.0 botocore/1.12.15
+
 
 +
Verification:
 +
 
 +
aws --version
 +
aws-cli/2.0.35 Python/3.7.4 Darwin/18.7.0 botocore/2.0.0dev39
 +
 
 +
==Uninstall AWS CLI Version 1==
 +
<syntaxhighlight lang='bash'>
 +
sudo rm -rf /usr/local/aws
 +
sudo rm /usr/local/bin/aws
 +
</syntaxhighlight>
  
 
=Configuration=
 
=Configuration=

Revision as of 20:27, 30 July 2020

External

Internal

Overview

AWS CLI is a package that provides commands for interacting with the AWS services. All functionality available on the web Amazon Management Console is made available from command line.

Installation

https://docs.aws.amazon.com/cli/latest/userguide/awscli-install-bundle.html
https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html

This article documents installation of AWS CLI v2.

curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /

Even it looks odd, "-target /" will install AWS CLI in /usr/local/aws-cli.

Verification:

aws --version aws-cli/2.0.35 Python/3.7.4 Darwin/18.7.0 botocore/2.0.0dev39

Uninstall AWS CLI Version 1

sudo rm -rf /usr/local/aws
sudo rm /usr/local/bin/aws

Configuration

Configuration Procedure

Once installed, AWS CLI can be configured by running:

aws configure

It will interactively inquire for AWS Access Key ID, etc.

Configuration Files

AWS CLI organizes configuration and credentials in two separate files placed in $USER/.aws. They are separated to isolate credentials for less sensitive options of region and output.

~/.aws/config

AWS CLI configuration file is maintained by default in ~/.aws/config:

[default]
region = us-west-2
ca_bundle = /path/to/ca-bundle.pem
output=json

[profile testing]
region = us-west-1

[profile testing2]
region = eu-west-1

[preview]
cloudsearch = true

~/.aws/credentials

AWS CLI credentials are maintained by default in ~/.aws/credentials:

[default]
aws_access_key_id=...
aws_secret_access_key=...

Configuration Profile

https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html#cli-multiple-profiles

The initial configuration procedure creates a profile named "default". Additional named profiles can be created, and then referred from command line with --profile.

Profiles can be created with:

aws configure set

Selecting a Profile

A previously-configured profile can be selected by setting the "AWS_PROFILE" environment variable:

export AWS_PROFILE=jenkins

Test Installation

aws ec2 describe-regions
aws ec2 describe-hosts

Credential Providers

Credential Providers

TODO

Define the relationship between the AWS CLI and EC2 CLI