AWS » Command Line Interface

Configuring the ~/.aws/credentials and ~/.aws/config files for use by the AWS cli and git

  1. Ensure AWS CLI is installed
    curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
    unzip awscliv2.zip
    ./aws/install
  2.  ~/.aws/credentials is created
    [testCredentials]
    aws_access_key_id = A******************L
    aws_secret_access_key = g*****************************************g
    
  3.  ~/.aws/config is created and correct - for the role to access with and the users's MFA (if set up, it almost certainly is)
    [default]
    region=eu-west-2
    output=json
    
    [profile testProfile]
    region=eu-west-2
    output=json
    source_profile=testCredentials
    role_arn=arn:aws:iam::1xxxxxxxxxx1:role/Administrator
    mfa_serial=arn:aws:iam::4xxxxxxxxxx2:mfa/paul.sullivan
    
  4. construct a command...
    /usr/local/bin/aws s3 ls --profile testProfile s3://somebucket

ASCII / UTF8 - character sets

If you are using AWS cli in bash ascii environment release that AWS is UTF-8 based - so you might get an error like:

'ascii' codec can't encode character '\xe9' in position 2: ordinal not in range(128)

The fix for this is to switch to a UTF-8 charset like this:

root@db:~# export LANG=C.UTF-8


Happy to work as an Employee, Consultant, Contractor / Self Employed or via Limited Company