Skip to content

Instantly share code, notes, and snippets.

@jeshan
Created October 30, 2020 12:58
Show Gist options
  • Save jeshan/baebf6b23237c93af6dfaad4d3a87351 to your computer and use it in GitHub Desktop.
Save jeshan/baebf6b23237c93af6dfaad4d3a87351 to your computer and use it in GitHub Desktop.
How to pass environment variables to other processes in AWS Codebuild, e.g docker compose commands
{
"version": 0.2,
"phases": {
"build": {
"commands": [
"curl 169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI > creds_json",
"export AWS_ACCESS_KEY_ID=$(cat creds_json | jq .AccessKeyId |tr -d '\"')",
"export AWS_SECRET_ACCESS_KEY=$(cat creds_json | jq .SecretAccessKey | tr -d '\"')",
"export AWS_SESSION_TOKEN=$(cat creds_json | jq .Token |tr -d '\"')",
"export CDK_DEFAULT_ACCOUNT=$CDK_DEFAULT_ACCOUNT",
"export CDK_DEFAULT_REGION=$CDK_DEFAULT_REGION",
"docker-compose up --build"
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment