The AWS CLI allows users to interact directly with AWS services such S3, Athena, and Glue. Authenticating via the CLI also allows users to interact with these services through analytics tools like R and Tableau.
Our account setup requires multi-factor authentication (MFA) to use most services. The easiest way to setup MFA is using the third-party aws-mfa
tool.
- Install the AWS command line interface using the provided executable or
pip install awscli
, which allows users to store credentials, query Athena, move S3 objects, etc. The CLI on Windows can be accessed via PowerShell. On Linux or macOS it can be accessed via a standard terminal. If your intention is to connect to AWS via the Data team server, ensure that you are connected and logged in to the server first. - Log into the AWS Console and under your account select "My Security Credentials". Enable MFA, then create an access key. You'll need both the
Access Key ID
, theSecret Access Key
, and the name of theAssigned MFA Device
. Do not include(Virtual)
when copying the name of the MFA device. - In the command line run:
aws configure
and enter yourAccess Key ID
,Secret Access Key
, region (us-east-1
), andjson
for output.pip install aws-mfa
- Open your credentials file located at
~/.aws/credentials
on Linux or macOS, or atC:\Users\$USERNAME\.aws\credentials
on Windows and rename[default]
to[default-long-term]
. - Underneath
aws_secret_access_key
typeaws_mfa_device = $MFA_DEVICE
where$MFA_DEVICE
is the previously copiedAssigned MFA Device
from the AWS Console. Save the file. - In the command line, run
aws-mfa
and enter the current MFA token provided by yourAssigned MFA Device
. - Note, this command will only store MFA credentials for 12 hours (unless the duration is explicitly changed when running
aws-mfa
).
Note, when connecting through the VPN or working in-office, you may encounter a TLS error when trying to authenticate with AWS on Windows. This error is due to certificate chain issues with the AWS CLI. You can fix it by exporting the CCAO's root CA bundle and providing the path in the C:\Users\$USERNAME\.aws\config
file.
- Search
Manage user certificates
in the Windows search bar. Then find the CCAO-specific root certificate underTrusted Root Certificate Authorities > Certificates
. - Right-click the CCAO CA, then click
All Tasks > Export
. - Export the CA bundle in the base-64 X.509 format. Save the exported CA bundle somewhere accessible.
- Open the configuration file at
C:\Users\$USERNAME\.aws\config
and add the lineca_bundle = $PATH_TO_EXPORTED_CERT
, where$PATH_TO_EXPORTED_CERT
is the path to the root CA file you just generated.
Most of this README originates from these sources: