Skip to content

Commit dbae96e

Browse files
RUBY-3672 Use AWS Secrets Manager for AWS auth test credentials (#3047)
1 parent c3a8223 commit dbae96e

4 files changed

Lines changed: 18 additions & 60 deletions

File tree

.evergreen/config.yml

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -157,35 +157,13 @@ functions:
157157
file: mo-expansion.yml
158158

159159
"export AWS auth credentials":
160-
- command: shell.exec
160+
- command: subprocess.exec
161161
type: test
162162
params:
163-
silent: true
164-
working_dir: "src"
165-
script: |
166-
cat <<EOT > .env.private
167-
IAM_AUTH_ASSUME_AWS_ACCOUNT="${iam_auth_assume_aws_account}"
168-
IAM_AUTH_ASSUME_AWS_SECRET_ACCESS_KEY="${iam_auth_assume_aws_secret_access_key}"
169-
IAM_AUTH_ASSUME_ROLE_NAME="${iam_auth_assume_role_name}"
170-
IAM_AUTH_EC2_INSTANCE_ACCOUNT="${iam_auth_ec2_instance_account}"
171-
IAM_AUTH_EC2_INSTANCE_PROFILE="${iam_auth_ec2_instance_profile}"
172-
IAM_AUTH_EC2_INSTANCE_SECRET_ACCESS_KEY="${iam_auth_ec2_instance_secret_access_key}"
173-
IAM_AUTH_ECS_ACCOUNT="${iam_auth_ecs_account}"
174-
IAM_AUTH_ECS_ACCOUNT_ARN="${iam_auth_ecs_account_arn}"
175-
IAM_AUTH_ECS_CLUSTER="${iam_auth_ecs_cluster}"
176-
IAM_AUTH_ECS_SECRET_ACCESS_KEY="${iam_auth_ecs_secret_access_key}"
177-
IAM_AUTH_ECS_SECURITY_GROUP="${iam_auth_ecs_security_group}"
178-
IAM_AUTH_ECS_SUBNET_A="${iam_auth_ecs_subnet_a}"
179-
IAM_AUTH_ECS_SUBNET_B="${iam_auth_ecs_subnet_b}"
180-
IAM_AUTH_ECS_TASK_DEFINITION="${iam_auth_ecs_task_definition_ubuntu2004}"
181-
182-
IAM_WEB_IDENTITY_ISSUER="${iam_web_identity_issuer}"
183-
IAM_WEB_IDENTITY_JWKS_URI="${iam_web_identity_jwks_uri}"
184-
IAM_WEB_IDENTITY_RSA_KEY="${iam_web_identity_rsa_key}"
185-
IAM_WEB_IDENTITY_TOKEN_FILE="${iam_web_identity_token_file}"
186-
IAM_AUTH_ASSUME_WEB_ROLE_NAME="${iam_auth_assume_web_role_name}"
187-
188-
EOT
163+
binary: bash
164+
include_expansions_in_env: [AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, DRIVERS_TOOLS]
165+
args:
166+
- "${DRIVERS_TOOLS}/.evergreen/auth_aws/setup-secrets.sh"
189167

190168
"run CSOT tests":
191169
- command: shell.exec

.evergreen/config/common.yml.erb

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -154,35 +154,13 @@ functions:
154154
file: mo-expansion.yml
155155

156156
"export AWS auth credentials":
157-
- command: shell.exec
157+
- command: subprocess.exec
158158
type: test
159159
params:
160-
silent: true
161-
working_dir: "src"
162-
script: |
163-
cat <<EOT > .env.private
164-
IAM_AUTH_ASSUME_AWS_ACCOUNT="${iam_auth_assume_aws_account}"
165-
IAM_AUTH_ASSUME_AWS_SECRET_ACCESS_KEY="${iam_auth_assume_aws_secret_access_key}"
166-
IAM_AUTH_ASSUME_ROLE_NAME="${iam_auth_assume_role_name}"
167-
IAM_AUTH_EC2_INSTANCE_ACCOUNT="${iam_auth_ec2_instance_account}"
168-
IAM_AUTH_EC2_INSTANCE_PROFILE="${iam_auth_ec2_instance_profile}"
169-
IAM_AUTH_EC2_INSTANCE_SECRET_ACCESS_KEY="${iam_auth_ec2_instance_secret_access_key}"
170-
IAM_AUTH_ECS_ACCOUNT="${iam_auth_ecs_account}"
171-
IAM_AUTH_ECS_ACCOUNT_ARN="${iam_auth_ecs_account_arn}"
172-
IAM_AUTH_ECS_CLUSTER="${iam_auth_ecs_cluster}"
173-
IAM_AUTH_ECS_SECRET_ACCESS_KEY="${iam_auth_ecs_secret_access_key}"
174-
IAM_AUTH_ECS_SECURITY_GROUP="${iam_auth_ecs_security_group}"
175-
IAM_AUTH_ECS_SUBNET_A="${iam_auth_ecs_subnet_a}"
176-
IAM_AUTH_ECS_SUBNET_B="${iam_auth_ecs_subnet_b}"
177-
IAM_AUTH_ECS_TASK_DEFINITION="${iam_auth_ecs_task_definition_ubuntu2004}"
178-
179-
IAM_WEB_IDENTITY_ISSUER="${iam_web_identity_issuer}"
180-
IAM_WEB_IDENTITY_JWKS_URI="${iam_web_identity_jwks_uri}"
181-
IAM_WEB_IDENTITY_RSA_KEY="${iam_web_identity_rsa_key}"
182-
IAM_WEB_IDENTITY_TOKEN_FILE="${iam_web_identity_token_file}"
183-
IAM_AUTH_ASSUME_WEB_ROLE_NAME="${iam_auth_assume_web_role_name}"
184-
185-
EOT
160+
binary: bash
161+
include_expansions_in_env: [AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, DRIVERS_TOOLS]
162+
args:
163+
- "${DRIVERS_TOOLS}/.evergreen/auth_aws/setup-secrets.sh"
186164

187165
"run CSOT tests":
188166
- command: shell.exec

.evergreen/functions-aws.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ clear_instance_profile() {
99
# the main shell environment, which uses different credentials for
1010
# regular and assume role configurations.
1111
(
12-
# When running in Evergreen, credentials are written to this file.
13-
# In Docker they are already in the environment and the file does not exist.
14-
if test -f .env.private; then
12+
# Source credentials from AWS Secrets Manager (CI) or .env.private (local/Docker).
13+
if test -n "${DRIVERS_TOOLS:-}" && test -f "${DRIVERS_TOOLS}/.evergreen/auth_aws/secrets-export.sh"; then
14+
. "${DRIVERS_TOOLS}/.evergreen/auth_aws/secrets-export.sh"
15+
elif test -f .env.private; then
1516
. ./.env.private
1617
fi
1718

.evergreen/run-tests-aws-auth.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ set +x
66

77
. `dirname "$0"`/functions.sh
88

9-
# When running in Evergreen, credentials are written to this file.
10-
# In Docker they are already in the environment and the file does not exist.
11-
if test -f .env.private; then
9+
# Source credentials from AWS Secrets Manager (CI) or .env.private (local/Docker).
10+
if test -n "${DRIVERS_TOOLS:-}" && test -f "${DRIVERS_TOOLS}/.evergreen/auth_aws/secrets-export.sh"; then
11+
. "${DRIVERS_TOOLS}/.evergreen/auth_aws/secrets-export.sh"
12+
elif test -f .env.private; then
1213
. ./.env.private
1314
fi
1415

0 commit comments

Comments
 (0)