Skip to content

AWS Authentication

Set up your AWS credentials. For more information, see Configuration and credential file settings.

Make sure you go through this setup first:

  1. Setup macOS for AWS Cloud DevOps

Scripts are bash

AWS CLI

Run aws configure to configure access key ID and secret access key, default region. Request access key ID and secret access key from you AWS admin.

# To configure the default profile:
aws configure

# To configure a specific named profile, e.g. `swift`:
aws configure --profile swift
- Specify Access key ID - Specify Secret access key - Set us-west-2 for region - Set json for output format

IMPORTANT: Disable CLI pager. Otherwise you will not be able to parse AWS CLI json responses:

aws configure set cli_pager ""

The files generated by the CLI for a default profile configured with aws configure looks similar to the following.

cat ~/.aws/credentials
[default]
aws_access_key_id=QWERTYUIOPASDFGHJKLZ
aws_secret_access_key=abcdEfgHijklm/NOPQARS/BxcfghGHEXAMPLEKEY
cat ~/.aws/config
[default]
region=us-west-2
output=json

Test:

aws ec2 describe-instances

EC2 Key Pair

Generate EC2 SSH key pair:

ssh-keygen -t rsa -C "aws-ec2-key" -f ~/.ssh/aws-ec2-key

Import the key in AWS EC2:

aws ec2 import-key-pair --key-name "aws-ec2-key" --public-key-material fileb://~/.ssh/aws-ec2-key.pub