Skip to content

Commit 6f0da2f

Browse files
web identitiy
1 parent 26fd38d commit 6f0da2f

File tree

4 files changed

+77
-88
lines changed

4 files changed

+77
-88
lines changed

.evergreen/config.in.yml

Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -598,61 +598,69 @@ functions:
598598
- .evergreen/run-mongodb-aws-test-copy.sh
599599

600600
"run aws auth test AssumeRoleWithWebIdentity with AWS_ROLE_SESSION_NAME set":
601-
- command: shell.exec
602-
type: test
601+
- command: ec2.assume_role
603602
params:
604-
working_dir: "src"
605-
silent: true
606-
shell: bash
607-
script: |
608-
set -ex
609-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
610-
. ./activate-authawsvenv.sh
611-
python aws_tester.py web-identity
612-
cd -
613-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
614-
export AWS_WEB_IDENTITY_TOKEN_FILE=${iam_web_identity_token_file}
615-
export AWS_ROLE_ARN=${iam_auth_assume_web_role_name}
616-
export AWS_ROLE_SESSION_NAME='test'
617-
export MONGODB_URI="mongodb://localhost:27017/aws?authMechanism=MONGODB-AWS"
618-
EOF
619-
- command: shell.exec
603+
role_arn: ${OIDC_AWS_ROLE_ARN}
604+
- command: subprocess.exec
620605
type: test
621606
params:
607+
include_expansions_in_env:
608+
- MONGODB_URI
609+
- DRIVERS_TOOLS
610+
- MONGODB_AWS_SDK
622611
env:
623-
MONGODB_AWS_SDK: ${MONGODB_AWS_SDK}
612+
AWS_CREDENTIAL_TYPE: web-identity
613+
AWS_ROLE_SESSION_NAME: test
624614
working_dir: "src"
625-
script: |
626-
${PREPARE_SHELL}
627-
${PROJECT_DIRECTORY}/.evergreen/run-mongodb-aws-test.sh
615+
binary: bash
616+
args:
617+
- .evergreen/run-mongodb-aws-test-copy.sh
618+
619+
# - command: shell.exec
620+
# type: test
621+
# params:
622+
# working_dir: "src"
623+
# silent: true
624+
# shell: bash
625+
# script: |
626+
# set -ex
627+
# cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
628+
# . ./activate-authawsvenv.sh
629+
# python aws_tester.py web-identity
630+
# cd -
631+
# cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
632+
# export AWS_WEB_IDENTITY_TOKEN_FILE=${iam_web_identity_token_file}
633+
# export AWS_ROLE_ARN=${iam_auth_assume_web_role_name}
634+
# export AWS_ROLE_SESSION_NAME='test'
635+
# export MONGODB_URI="mongodb://localhost:27017/aws?authMechanism=MONGODB-AWS"
636+
# EOF
637+
# - command: shell.exec
638+
# type: test
639+
# params:
640+
# env:
641+
# MONGODB_AWS_SDK: ${MONGODB_AWS_SDK}
642+
# working_dir: "src"
643+
# script: |
644+
# ${PREPARE_SHELL}
645+
# ${PROJECT_DIRECTORY}/.evergreen/run-mongodb-aws-test.sh
628646

629647
"run aws auth test AssumeRoleWithWebIdentity with AWS_ROLE_SESSION_NAME unset":
630-
- command: shell.exec
631-
type: test
648+
- command: ec2.assume_role
632649
params:
633-
working_dir: "src"
634-
silent: true
635-
shell: bash
636-
script: |
637-
set -ex
638-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
639-
. ./activate-authawsvenv.sh
640-
python aws_tester.py web-identity
641-
cd -
642-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
643-
export AWS_WEB_IDENTITY_TOKEN_FILE=${iam_web_identity_token_file}
644-
export AWS_ROLE_ARN=${iam_auth_assume_web_role_name}
645-
export MONGODB_URI="mongodb://localhost:27017/aws?authMechanism=MONGODB-AWS"
646-
EOF
647-
- command: shell.exec
650+
role_arn: ${OIDC_AWS_ROLE_ARN}
651+
- command: subprocess.exec
648652
type: test
649653
params:
654+
include_expansions_in_env:
655+
- MONGODB_URI
656+
- DRIVERS_TOOLS
657+
- MONGODB_AWS_SDK
650658
env:
651-
MONGODB_AWS_SDK: ${MONGODB_AWS_SDK}
659+
AWS_CREDENTIAL_TYPE: web-identity
652660
working_dir: "src"
653-
script: |
654-
${PREPARE_SHELL}
655-
${PROJECT_DIRECTORY}/.evergreen/run-mongodb-aws-test.sh
661+
binary: bash
662+
args:
663+
- .evergreen/run-mongodb-aws-test-copy.sh
656664

657665
"run aws ECS auth test":
658666
- command: shell.exec

.evergreen/config.yml

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -536,60 +536,40 @@ functions:
536536
args:
537537
- .evergreen/run-mongodb-aws-test-copy.sh
538538
run aws auth test AssumeRoleWithWebIdentity with AWS_ROLE_SESSION_NAME set:
539-
- command: shell.exec
540-
type: test
539+
- command: ec2.assume_role
541540
params:
542-
working_dir: src
543-
silent: true
544-
shell: bash
545-
script: |
546-
set -ex
547-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
548-
. ./activate-authawsvenv.sh
549-
python aws_tester.py web-identity
550-
cd -
551-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
552-
export AWS_WEB_IDENTITY_TOKEN_FILE=${iam_web_identity_token_file}
553-
export AWS_ROLE_ARN=${iam_auth_assume_web_role_name}
554-
export AWS_ROLE_SESSION_NAME='test'
555-
export MONGODB_URI="mongodb://localhost:27017/aws?authMechanism=MONGODB-AWS"
556-
EOF
557-
- command: shell.exec
541+
role_arn: ${OIDC_AWS_ROLE_ARN}
542+
- command: subprocess.exec
558543
type: test
559544
params:
545+
include_expansions_in_env:
546+
- MONGODB_URI
547+
- DRIVERS_TOOLS
548+
- MONGODB_AWS_SDK
560549
env:
561-
MONGODB_AWS_SDK: ${MONGODB_AWS_SDK}
550+
AWS_CREDENTIAL_TYPE: web-identity
551+
AWS_ROLE_SESSION_NAME: test
562552
working_dir: src
563-
script: |
564-
${PREPARE_SHELL}
565-
${PROJECT_DIRECTORY}/.evergreen/run-mongodb-aws-test.sh
553+
binary: bash
554+
args:
555+
- .evergreen/run-mongodb-aws-test-copy.sh
566556
run aws auth test AssumeRoleWithWebIdentity with AWS_ROLE_SESSION_NAME unset:
567-
- command: shell.exec
568-
type: test
557+
- command: ec2.assume_role
569558
params:
570-
working_dir: src
571-
silent: true
572-
shell: bash
573-
script: |
574-
set -ex
575-
cd ${DRIVERS_TOOLS}/.evergreen/auth_aws
576-
. ./activate-authawsvenv.sh
577-
python aws_tester.py web-identity
578-
cd -
579-
cat <<'EOF' > "${PROJECT_DIRECTORY}/prepare_mongodb_aws.sh"
580-
export AWS_WEB_IDENTITY_TOKEN_FILE=${iam_web_identity_token_file}
581-
export AWS_ROLE_ARN=${iam_auth_assume_web_role_name}
582-
export MONGODB_URI="mongodb://localhost:27017/aws?authMechanism=MONGODB-AWS"
583-
EOF
584-
- command: shell.exec
559+
role_arn: ${OIDC_AWS_ROLE_ARN}
560+
- command: subprocess.exec
585561
type: test
586562
params:
563+
include_expansions_in_env:
564+
- MONGODB_URI
565+
- DRIVERS_TOOLS
566+
- MONGODB_AWS_SDK
587567
env:
588-
MONGODB_AWS_SDK: ${MONGODB_AWS_SDK}
568+
AWS_CREDENTIAL_TYPE: web-identity
589569
working_dir: src
590-
script: |
591-
${PREPARE_SHELL}
592-
${PROJECT_DIRECTORY}/.evergreen/run-mongodb-aws-test.sh
570+
binary: bash
571+
args:
572+
- .evergreen/run-mongodb-aws-test-copy.sh
593573
run aws ECS auth test:
594574
- command: shell.exec
595575
type: test

.evergreen/generate_evergreen_tasks.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,11 @@ for (const VERSION of AWS_AUTH_VERSIONS) {
344344
{ func: 'run aws auth test with aws credentials and session token as environment variables' }, // done
345345
{ func: 'run aws ECS auth test' },
346346
{
347-
func: 'run aws auth test AssumeRoleWithWebIdentity with AWS_ROLE_SESSION_NAME unset',
347+
func: 'run aws auth test AssumeRoleWithWebIdentity with AWS_ROLE_SESSION_NAME unset', // done
348348
onlySdk: true
349349
},
350350
{
351-
func: 'run aws auth test AssumeRoleWithWebIdentity with AWS_ROLE_SESSION_NAME set',
351+
func: 'run aws auth test AssumeRoleWithWebIdentity with AWS_ROLE_SESSION_NAME set', // done
352352
onlySdk: true
353353
}
354354
];

test/integration/auth/mongodb_aws.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424

2525
const isMongoDBAWSAuthEnvironment = (process.env.MONGODB_URI ?? '').includes('MONGODB-AWS');
2626

27+
console.error(`IS THIS SET?: ${'AWS_ROLE_SESSION_NAME' in process.env}`)
2728
describe('MONGODB-AWS', function () {
2829
let awsSdkPresent;
2930
let client: MongoClient;

0 commit comments

Comments
 (0)