Skip to content

Instantly share code, notes, and snippets.

@wobondar
Created August 22, 2018 15:43
Show Gist options
  • Select an option

  • Save wobondar/b02b01e5264e2d7a780e83e83561e4bd to your computer and use it in GitHub Desktop.

Select an option

Save wobondar/b02b01e5264e2d7a780e83e83561e4bd to your computer and use it in GitHub Desktop.
AWS CodeBuild container credentials
#!/usr/bin/env bash
curl -qL 169.254.170.2/$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI > credentials.json
mkdir -p ~/.aws
echo "[default]" > ~/.aws/credentials
echo "aws_access_key_id = $(cat credentials.json | jq '.AccessKeyId' | sed s'/"//g')" >> ~/.aws/credentials
echo "aws_secret_access_key = $(cat credentials.json | jq '.SecretAccessKey' | sed s'/"//g')" >> ~/.aws/credentials
echo "aws_session_token = $(cat credentials.json | jq '.Token' | sed s'/"//g')" >> ~/.aws/credentials
rm credentials.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment