Skip to content

Commit d056804

Browse files
authored
PYTHON-2818 Add native support for AWS IAM Roles for service accounts, EKS in particular (#1032)
1 parent fcb1151 commit d056804

File tree

1 file changed

+77
-3
lines changed

1 file changed

+77
-3
lines changed

.evergreen/config.yml

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,13 @@ functions:
572572
573573
"iam_auth_ec2_instance_account" : "${iam_auth_ec2_instance_account}",
574574
"iam_auth_ec2_instance_secret_access_key" : "${iam_auth_ec2_instance_secret_access_key}",
575-
"iam_auth_ec2_instance_profile" : "${iam_auth_ec2_instance_profile}"
575+
"iam_auth_ec2_instance_profile" : "${iam_auth_ec2_instance_profile}",
576+
577+
"iam_auth_assume_web_role_name": "${iam_auth_assume_web_role_name}",
578+
"iam_web_identity_issuer": "${iam_web_identity_issuer}",
579+
"iam_web_identity_rsa_key": "${iam_web_identity_rsa_key}",
580+
"iam_web_identity_jwks_uri": "${iam_web_identity_jwks_uri}",
581+
"iam_web_identity_token_file": "${iam_web_identity_token_file}"
576582
}
577583
EOF
578584
@@ -668,7 +674,67 @@ functions:
668674
fi
669675
# Write an empty prepare_mongodb_aws so no auth environment variables
670676
# are set.
671-
echo "" > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
677+
rm "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh" || true
678+
PYTHON_BINARY=${PYTHON_BINARY} ASSERT_NO_URI_CREDS=true .evergreen/run-mongodb-aws-test.sh
679+
680+
"run aws auth test with aws web identity credentials":
681+
- command: shell.exec
682+
type: test
683+
params:
684+
working_dir: "src"
685+
script: |
686+
${PREPARE_SHELL}
687+
if [ "${skip_EC2_auth_test}" = "true" ]; then
688+
echo "This platform does not support the web identity auth test, skipping..."
689+
exit 0
690+
fi
691+
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
692+
. ./activate_venv.sh
693+
mongo aws_e2e_web_identity.js
694+
- command: shell.exec
695+
type: test
696+
params:
697+
working_dir: "src"
698+
silent: true
699+
script: |
700+
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
701+
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
702+
export AWS_ROLE_ARN="${iam_auth_assume_web_role_name}"
703+
export AWS_WEB_IDENTITY_TOKEN_FILE="${iam_web_identity_token_file}"
704+
EOF
705+
- command: shell.exec
706+
type: test
707+
params:
708+
working_dir: "src"
709+
script: |
710+
${PREPARE_SHELL}
711+
if [ "${skip_web_identity_auth_test}" = "true" ]; then
712+
echo "This platform does not support the web identity auth test, skipping..."
713+
exit 0
714+
fi
715+
PYTHON_BINARY=${PYTHON_BINARY} ASSERT_NO_URI_CREDS=true .evergreen/run-mongodb-aws-test.sh
716+
- command: shell.exec
717+
type: test
718+
params:
719+
working_dir: "src"
720+
silent: true
721+
script: |
722+
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
723+
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
724+
export AWS_ROLE_ARN="${iam_auth_assume_web_role_name}"
725+
export AWS_WEB_IDENTITY_TOKEN_FILE="${iam_web_identity_token_file}"
726+
export AWS_ROLE_SESSION_NAME="test"
727+
EOF
728+
- command: shell.exec
729+
type: test
730+
params:
731+
working_dir: "src"
732+
script: |
733+
${PREPARE_SHELL}
734+
if [ "${skip_web_identity_auth_test}" = "true" ]; then
735+
echo "This platform does not support the web identity auth test, skipping..."
736+
exit 0
737+
fi
672738
PYTHON_BINARY=${PYTHON_BINARY} ASSERT_NO_URI_CREDS=true .evergreen/run-mongodb-aws-test.sh
673739
674740
"run aws auth test with aws credentials as environment variables":
@@ -1832,6 +1898,7 @@ tasks:
18321898
- func: "run aws auth test with aws credentials as environment variables"
18331899
- func: "run aws auth test with aws credentials and session token as environment variables"
18341900
- func: "run aws auth test with aws EC2 credentials"
1901+
- func: "run aws auth test with aws web identity credentials"
18351902
- func: "run aws ECS auth test"
18361903

18371904
- name: "aws-auth-test-5.0"
@@ -1848,6 +1915,7 @@ tasks:
18481915
- func: "run aws auth test with aws credentials as environment variables"
18491916
- func: "run aws auth test with aws credentials and session token as environment variables"
18501917
- func: "run aws auth test with aws EC2 credentials"
1918+
- func: "run aws auth test with aws web identity credentials"
18511919
- func: "run aws ECS auth test"
18521920

18531921
- name: "aws-auth-test-6.0"
@@ -1864,6 +1932,7 @@ tasks:
18641932
- func: "run aws auth test with aws credentials as environment variables"
18651933
- func: "run aws auth test with aws credentials and session token as environment variables"
18661934
- func: "run aws auth test with aws EC2 credentials"
1935+
- func: "run aws auth test with aws web identity credentials"
18671936
- func: "run aws ECS auth test"
18681937

18691938
- name: "aws-auth-test-latest"
@@ -1880,6 +1949,7 @@ tasks:
18801949
- func: "run aws auth test with aws credentials as environment variables"
18811950
- func: "run aws auth test with aws credentials and session token as environment variables"
18821951
- func: "run aws auth test with aws EC2 credentials"
1952+
- func: "run aws auth test with aws web identity credentials"
18831953
- func: "run aws ECS auth test"
18841954
- name: "aws-auth-test-rapid"
18851955
commands:
@@ -1895,6 +1965,7 @@ tasks:
18951965
- func: "run aws auth test with aws credentials as environment variables"
18961966
- func: "run aws auth test with aws credentials and session token as environment variables"
18971967
- func: "run aws auth test with aws EC2 credentials"
1968+
- func: "run aws auth test with aws web identity credentials"
18981969
- func: "run aws ECS auth test"
18991970

19001971
- name: load-balancer-test
@@ -2076,6 +2147,7 @@ axes:
20762147
variables:
20772148
skip_EC2_auth_test: true
20782149
skip_ECS_auth_test: true
2150+
skip_web_identity_auth_test: true
20792151
python3_binary: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3
20802152
libmongocrypt_url: https://s3.amazonaws.com/mciuploads/libmongocrypt/macos/master/latest/libmongocrypt.tar.gz
20812153
- id: macos-1100
@@ -2084,6 +2156,7 @@ axes:
20842156
variables:
20852157
skip_EC2_auth_test: true
20862158
skip_ECS_auth_test: true
2159+
skip_web_identity_auth_test: true
20872160
python3_binary: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3
20882161
libmongocrypt_url: https://s3.amazonaws.com/mciuploads/libmongocrypt/macos/master/latest/libmongocrypt.tar.gz
20892162
- id: rhel62
@@ -2146,8 +2219,9 @@ axes:
21462219
run_on: windows-64-vsMulti-small
21472220
batchtime: 10080 # 7 days
21482221
variables:
2149-
skip_EC2_auth_test: true
21502222
skip_ECS_auth_test: true
2223+
skip_EC2_auth_test: true
2224+
skip_web_identity_auth_test: true
21512225
python3_binary: "C:/python/Python38/python.exe"
21522226
venv_bin_dir: "Scripts"
21532227
libmongocrypt_url: https://s3.amazonaws.com/mciuploads/libmongocrypt/windows-test/master/latest/libmongocrypt.tar.gz

0 commit comments

Comments
 (0)