AWS CLI

Table of contents
  1. Install
  2. Set up AWS CLI
    1. Configure credentials
    2. Show configuration
  3. Upload file to S3

Install

brew install awscli

Set up AWS CLI

Configure credentials

To create a named profile:

$ aws configure --profie ${profile_name}
AWS Access Key ID [None]: ...
AWS Secret Access Key [None]: ...
Default region name [None]: ...
Default output format [None]: json

You can create multiple profiles.

Your configuration is saved in two files: ~/.aws/config and ~/.aws/credentials.

To modify an existing profile you can either modify it directly in the files or use the aws configure command again:

$ aws configure set region ${value_to_set} --profile ${profile_name}

Show configuration

To see the list of all profiles:

aws configure list-profiles

To see the configuration of a specific profile:

aws configure list --profile ${profile_name}

To see the value of a specific variable of a specific profile:

aws configure get region --profile ${profile_name}

Upload file to S3

To upload a folder to a subdirectory in a bucket:

aws s3 cp ${dir_name} s3://${bucket_name}/${sub_dir}/${dir_name} --recursive --profile ${profile}

References: