Skip to content

Commit b6344d2

Browse files
RUST-906 Add native support for AWS IAM Roles for service accounts, EKS in particular (#885)
1 parent 220a3f7 commit b6344d2

File tree

4 files changed

+216
-138
lines changed

4 files changed

+216
-138
lines changed

.evergreen/config.yml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,12 @@ functions:
127127
"iam_auth_assume_role_name" : "${iam_auth_assume_role_name}",
128128
"iam_auth_ec2_instance_account" : "${iam_auth_ec2_instance_account}",
129129
"iam_auth_ec2_instance_secret_access_key" : "${iam_auth_ec2_instance_secret_access_key}",
130-
"iam_auth_ec2_instance_profile" : "${iam_auth_ec2_instance_profile}"
130+
"iam_auth_ec2_instance_profile" : "${iam_auth_ec2_instance_profile}",
131+
"iam_auth_assume_web_role_name": "${iam_auth_assume_web_role_name}",
132+
"iam_web_identity_issuer": "${iam_web_identity_issuer}",
133+
"iam_web_identity_jwks_uri": "${iam_web_identity_jwks_uri}",
134+
"iam_web_identity_token_file": "${iam_web_identity_token_file}",
135+
"iam_web_identity_rsa_key": "${iam_web_identity_rsa_key}"
131136
}
132137
EOF
133138
@@ -297,6 +302,46 @@ functions:
297302
cat setup.js
298303
mongo --nodb setup.js aws_e2e_ecs.js
299304
305+
"run aws assume role with web identity test":
306+
- command: shell.exec
307+
type: test
308+
params:
309+
shell: bash
310+
working_dir: "src"
311+
script: |
312+
${PREPARE_SHELL}
313+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
314+
. ./activate-authawsvenv.sh
315+
mongo aws_e2e_web_identity.js
316+
- command: shell.exec
317+
type: test
318+
params:
319+
working_dir: "src"
320+
silent: true
321+
script: |
322+
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
323+
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
324+
export AWS_ROLE_ARN="${iam_auth_assume_web_role_name}"
325+
export AWS_WEB_IDENTITY_TOKEN_FILE="${iam_web_identity_token_file}"
326+
EOF
327+
- command: shell.exec
328+
type: test
329+
params:
330+
shell: bash
331+
working_dir: "src"
332+
script: |
333+
# the test should be run with and without a session name set
334+
ASYNC_RUNTIME=${ASYNC_RUNTIME} \
335+
PROJECT_DIRECTORY=${PROJECT_DIRECTORY} \
336+
ASSERT_NO_URI_CREDS=true \
337+
AWS_ROLE_SESSION_NAME="test" \
338+
.evergreen/run-aws-tests.sh
339+
ASYNC_RUNTIME=${ASYNC_RUNTIME} \
340+
PROJECT_DIRECTORY=${PROJECT_DIRECTORY} \
341+
ASSERT_NO_URI_CREDS=true \
342+
.evergreen/run-aws-tests.sh
343+
344+
300345
"run x509 tests":
301346
- command: shell.exec
302347
type: test
@@ -1023,6 +1068,7 @@ tasks:
10231068
- func: "run aws auth test with aws credentials and session token as environment variables"
10241069
- func: "run aws auth test with aws EC2 credentials"
10251070
- func: "run aws ECS auth test"
1071+
- func: "run aws assume role with web identity test"
10261072

10271073
- name: "test-5.0-standalone"
10281074
tags: ["5.0", "standalone"]
@@ -1083,6 +1129,7 @@ tasks:
10831129
- func: "run aws auth test with aws credentials and session token as environment variables"
10841130
- func: "run aws auth test with aws EC2 credentials"
10851131
- func: "run aws ECS auth test"
1132+
- func: "run aws assume role with web identity test"
10861133

10871134
- name: "test-6.0-standalone"
10881135
tags: ["6.0", "standalone"]
@@ -1143,6 +1190,7 @@ tasks:
11431190
- func: "run aws auth test with aws credentials and session token as environment variables"
11441191
- func: "run aws auth test with aws EC2 credentials"
11451192
- func: "run aws ECS auth test"
1193+
- func: "run aws assume role with web identity test"
11461194

11471195
- name: "test-7.0-standalone"
11481196
tags: ["7.0", "standalone"]
@@ -1203,6 +1251,7 @@ tasks:
12031251
- func: "run aws auth test with aws credentials and session token as environment variables"
12041252
- func: "run aws auth test with aws EC2 credentials"
12051253
- func: "run aws ECS auth test"
1254+
- func: "run aws assume role with web identity test"
12061255

12071256
- name: "test-rapid-standalone"
12081257
tags: ["rapid", "standalone"]
@@ -1263,6 +1312,7 @@ tasks:
12631312
- func: "run aws auth test with aws credentials and session token as environment variables"
12641313
- func: "run aws auth test with aws EC2 credentials"
12651314
- func: "run aws ECS auth test"
1315+
- func: "run aws assume role with web identity test"
12661316

12671317
- name: "test-latest-standalone"
12681318
tags: ["latest", "standalone"]
@@ -1324,6 +1374,7 @@ tasks:
13241374
- func: "run aws auth test with aws credentials and session token as environment variables"
13251375
- func: "run aws auth test with aws EC2 credentials"
13261376
- func: "run aws ECS auth test"
1377+
- func: "run aws assume role with web identity test"
13271378

13281379
- name: "test-connection-string"
13291380
commands:

0 commit comments

Comments
 (0)