2019年7月22日 星期一

AWS CLI 設定

System info

  • Check Mac OS version
# sw_vers
ProductName:    Mac OS X
ProductVersion: 10.14.5
BuildVersion:   18F132

Install the AWS CLI on macOS Using pip

  • Check pip3 version
# pip3 --version
  • Install the AWS CLI on macOS Using pip
    1. Download and install the latest version of Python from the download page of Python.org
    2. Download and run the pip3 installation script.
      # curl -O https://bootstrap.pypa.io/get-pip.py
      # python3 get-pip.py --user
    3. Use pip3 to install the AWS CLI.
      # pip3 install awscli --upgrade --user
    4. Verify that the AWS CLI is installed correctly.
      # aws --version
      aws-cli/1.16.203 Python/3.7.3 Darwin/18.6.0 botocore/1.12.193
    5. To upgrade to the latest version, run the installation command again.
      # pip3 install awscli --upgrade --user
  • Add the AWS CLI Executable to Your macOS Command Line Path
    1. Find out AWS CLI installation path
      # which aws
      /Users/nobody/Library/Python/3.7/bin/aws
    2. To modify your PATH variable
      # echo 'export PATH=/Users/nobody/Library/Python/3.7/bin:$PATH >> ~/.zshrc
    3. Load the updated profile into your current session.
      # source ~/.zshrc

Configuration and Multiple Profiles for AWS

  • The aws configure command is the fastest way to set up your AWS CLI installation
# aws configure --profile "Your Name"
AWS Access Key ID [None]: "Your Access Key ID"
AWS Secret Access Key [None]: "Your Secret Access Key"
Default region name [None]: us-east-1
Default output format [None]: table
  • Output format:
    • json
    • text
    • table
  • List .aws directory
# tree ~/.aws
/Users/nobody/.aws
├── config
└── credentials
and your can see the config in ~/.aws/config and ~/.aws/credentials
  • Setting environment variable to get AWS config
# export AWS_DEFAULT_PROFILE=nobody
or
# echo 'export AWS_DEFAULT_PROFILE=nobody' >> ~/.zshrc
# source ~/.zshrc
  • List aws profiles
# aws configure list --profile nobody
  • Get Current Region
# aws configure get nobody.region
  • Use
Reference:

沒有留言:

張貼留言