Skip to content

Add integration test for AWS web identity credential fetching #1063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 79 additions & 1 deletion .evergreen/.evg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,13 @@ functions:

"iam_auth_ec2_instance_account" : "${iam_auth_ec2_instance_account}",
"iam_auth_ec2_instance_secret_access_key" : "${iam_auth_ec2_instance_secret_access_key}",
"iam_auth_ec2_instance_profile" : "${iam_auth_ec2_instance_profile}"
"iam_auth_ec2_instance_profile" : "${iam_auth_ec2_instance_profile}",

"iam_auth_assume_web_role_name": "${iam_auth_assume_web_role_name}",
"iam_web_identity_issuer": "${iam_web_identity_issuer}",
"iam_web_identity_rsa_key": "${iam_web_identity_rsa_key}",
"iam_web_identity_jwks_uri": "${iam_web_identity_jwks_uri}",
"iam_web_identity_token_file": "${iam_web_identity_token_file}"
}
EOF

Expand Down Expand Up @@ -429,6 +435,67 @@ functions:
echo "" > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} .evergreen/run-mongodb-aws-test.sh

"run aws auth test with web identity credentials":
- command: shell.exec
type: test
params:
working_dir: "src"
shell: "bash"
script: |
${PREPARE_SHELL}
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
. ./activate-authawsvenv.sh
mongo aws_e2e_web_identity.js
- command: shell.exec
type: test
params:
working_dir: "src"
shell: "bash"
silent: true
script: |
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
export AWS_ROLE_ARN="${iam_auth_assume_web_role_name}"
export AWS_WEB_IDENTITY_TOKEN_FILE="${iam_web_identity_token_file}"
EOF
- command: shell.exec
type: test
params:
working_dir: "src"
shell: "bash"
script: |
${PREPARE_SHELL}
if [ "${AWS_CREDENTIAL_PROVIDER}" = "builtIn" ]; then
echo "Built-in AWS credential provider does not support the web identity auth test, skipping..."
exit 0
fi
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} ASSERT_NO_URI_CREDS=true .evergreen/run-mongodb-aws-test.sh
- command: shell.exec
type: test
params:
working_dir: "src"
shell: "bash"
silent: true
script: |
# DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
export AWS_ROLE_ARN="${iam_auth_assume_web_role_name}"
export AWS_WEB_IDENTITY_TOKEN_FILE="${iam_web_identity_token_file}"
export AWS_ROLE_SESSION_NAME="test"
EOF
- command: shell.exec
type: test
params:
working_dir: "src"
shell: "bash"
script: |
${PREPARE_SHELL}
if [ "${AWS_CREDENTIAL_PROVIDER}" = "builtIn" ]; then
echo "Built-in AWS credential provider does not support the web identity auth test, skipping..."
exit 0
fi
JAVA_VERSION=${JAVA_VERSION} AWS_CREDENTIAL_PROVIDER=${AWS_CREDENTIAL_PROVIDER} ASSERT_NO_URI_CREDS=true .evergreen/run-mongodb-aws-test.sh

"run aws auth test with aws credentials as environment variables":
- command: shell.exec
type: test
Expand Down Expand Up @@ -884,6 +951,16 @@ tasks:
- func: "add aws auth variables to file"
- func: "run aws auth test with aws EC2 credentials"

- name: "aws-auth-test-with-web-identity-credentials"
commands:
- func: "bootstrap mongo-orchestration"
vars:
AUTH: "auth"
ORCHESTRATION_FILE: "auth-aws.json"
TOPOLOGY: "server"
- func: "add aws auth variables to file"
- func: "run aws auth test with web identity credentials"

- name: "aws-ECS-auth-test"
commands:
- func: "bootstrap mongo-orchestration"
Expand Down Expand Up @@ -1893,6 +1970,7 @@ buildvariants:
- name: "aws-auth-test-with-aws-credentials-as-environment-variables"
- name: "aws-auth-test-with-aws-credentials-and-session-token-as-environment-variables"
- name: "aws-auth-test-with-aws-EC2-credentials"
- name: "aws-auth-test-with-web-identity-credentials"

- matrix_name: "aws-ecs-auth-test"
matrix_spec: { ssl: "nossl", jdk: ["jdk8", "jdk17"], version: ["4.4", "5.0", "6.0", "latest"], os: "ubuntu" }
Expand Down
2 changes: 2 additions & 0 deletions driver-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ dependencies {
// Optionally depend on both AWS SDK v2 and v1. The driver will use v2 is present, v1 if present, or built-in functionality if
// neither are present
implementation "software.amazon.awssdk:auth:$awsSdkV2Version", optional
implementation "software.amazon.awssdk:sts:$awsSdkV2Version", optional
implementation "com.amazonaws:aws-java-sdk-core:$awsSdkV1Version", optional
implementation "com.amazonaws:aws-java-sdk-sts:$awsSdkV1Version", optional

implementation "org.xerial.snappy:snappy-java:$snappyVersion", optional
implementation "com.github.luben:zstd-jni:$zstdVersion", optional
Expand Down