diff --git a/README.md b/README.md index 1e4d1d9..46c0f24 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,7 @@ Note that only pipeline variables will automatically be propagated (what you see Whether or not to automatically propagate aws authentication environment variables into the docker container. Avoiding the need to be specified with `environment`. This is useful for example if you are using an assume role plugin. -Will propagate `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN`, only if they are set already. +Will propagate `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`, `AWS_REGION` and `AWS_DEFAULT_REGION`, only if they are set already. ### `propagate-uid-gid` (optional, boolean) diff --git a/hooks/command b/hooks/command index 67f9946..10c3110 100755 --- a/hooks/command +++ b/hooks/command @@ -280,6 +280,12 @@ if [[ "${BUILDKITE_PLUGIN_DOCKER_PROPAGATE_AWS_AUTH_TOKENS:-false}" =~ ^(true|on if [[ -n "${AWS_SESSION_TOKEN:-}" ]] ; then args+=( --env "AWS_SESSION_TOKEN" ) fi + if [[ -n "${AWS_REGION:-}" ]] ; then + args+=( --env "AWS_REGION" ) + fi + if [[ -n "${AWS_DEFAULT_REGION:-}" ]] ; then + args+=( --env "AWS_DEFAULT_REGION" ) + fi fi if [[ "${BUILDKITE_PLUGIN_DOCKER_ALWAYS_PULL:-false}" =~ ^(true|on|1)$ ]] ; then diff --git a/tests/command.bats b/tests/command.bats index fc8411c..0dd1a5f 100644 --- a/tests/command.bats +++ b/tests/command.bats @@ -698,9 +698,11 @@ EOF export AWS_ACCESS_KEY_ID="AKIAIOSFODNN7EXAMPLE" export AWS_SECRET_ACCESS_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" export AWS_SESSION_TOKEN="AQoEXAMPLEH4aoAH0gNCAPy...truncated...zrkuWJOgQs8IZZaIv2BXIa2R4Olgk" + export AWS_REGION="ap-southeast-2" + export AWS_DEFAULT_REGION="ap-southeast-2" stub docker \ - "run -it --rm --init --volume $PWD:/workdir --workdir /workdir --env AWS_ACCESS_KEY_ID --env AWS_SECRET_ACCESS_KEY --env AWS_SESSION_TOKEN --label com.buildkite.job-id=1-2-3-4 image:tag /bin/sh -e -c 'echo hello world' : echo ran command in docker" + "run -it --rm --init --volume $PWD:/workdir --workdir /workdir --env AWS_ACCESS_KEY_ID --env AWS_SECRET_ACCESS_KEY --env AWS_SESSION_TOKEN --env AWS_REGION --env AWS_DEFAULT_REGION --label com.buildkite.job-id=1-2-3-4 image:tag /bin/sh -e -c 'echo hello world' : echo ran command in docker" run $PWD/hooks/command @@ -790,4 +792,4 @@ EOF assert_output --partial "ran command in docker" unstub docker -} \ No newline at end of file +}