Skip to content

Commit 373fe17

Browse files
authored
RUST-2049 Fix search index helpers and AWS Lambda tests (#1217)
1 parent 7a408c3 commit 373fe17

File tree

2 files changed

+60
-16
lines changed

2 files changed

+60
-16
lines changed

.evergreen/config.yml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -543,21 +543,25 @@ task_groups:
543543
- func: "make files executable"
544544
- func: "install rust"
545545
- func: "install junit dependencies"
546+
- command: ec2.assume_role
547+
params:
548+
role_arn: ${aws_test_secrets_role}
546549
- command: subprocess.exec
547550
params:
548551
working_dir: src
549552
binary: bash
550553
include_expansions_in_env:
551-
- DRIVERS_ATLAS_PUBLIC_API_KEY
552-
- DRIVERS_ATLAS_PRIVATE_API_KEY
553-
- DRIVERS_ATLAS_GROUP_ID
554-
- DRIVERS_ATLAS_LAMBDA_USER
555-
- DRIVERS_ATLAS_LAMBDA_PASSWORD
554+
- AWS_ACCESS_KEY_ID
555+
- AWS_SECRET_ACCESS_KEY
556+
- AWS_SESSION_TOKEN
557+
- DRIVERS_TOOLS
556558
- LAMBDA_STACK_NAME
557559
- MONGODB_VERSION
558560
env:
559561
MONGODB_VERSION: "7.0"
560562
args:
563+
- .evergreen/with-secrets.sh
564+
- drivers/atlas-dev
561565
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
562566
- command: expansions.update
563567
params:
@@ -568,11 +572,10 @@ task_groups:
568572
working_dir: src
569573
binary: bash
570574
include_expansions_in_env:
571-
- DRIVERS_ATLAS_PUBLIC_API_KEY
572-
- DRIVERS_ATLAS_PRIVATE_API_KEY
573-
- DRIVERS_ATLAS_GROUP_ID
574575
- CLUSTER_NAME
575576
args:
577+
- .evergreen/with-secrets.sh
578+
- drivers/atlas-dev
576579
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
577580
- func: "upload test results"
578581
tasks:
@@ -588,19 +591,23 @@ task_groups:
588591
- func: "make files executable"
589592
- func: "install rust"
590593
- func: "install cargo-lambda"
594+
- command: ec2.assume_role
595+
params:
596+
role_arn: ${aws_test_secrets_role}
591597
- command: subprocess.exec
592598
params:
593599
working_dir: src
594600
binary: bash
595601
include_expansions_in_env:
596-
- DRIVERS_ATLAS_PUBLIC_API_KEY
597-
- DRIVERS_ATLAS_PRIVATE_API_KEY
598-
- DRIVERS_ATLAS_GROUP_ID
599-
- DRIVERS_ATLAS_LAMBDA_USER
600-
- DRIVERS_ATLAS_LAMBDA_PASSWORD
602+
- AWS_ACCESS_KEY_ID
603+
- AWS_SECRET_ACCESS_KEY
604+
- AWS_SESSION_TOKEN
605+
- DRIVERS_TOOLS
601606
- LAMBDA_STACK_NAME
602607
- MONGODB_VERSION
603608
args:
609+
- .evergreen/with-secrets.sh
610+
- drivers/atlas-dev
604611
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
605612
- command: expansions.update
606613
params:
@@ -611,11 +618,10 @@ task_groups:
611618
working_dir: src
612619
binary: bash
613620
include_expansions_in_env:
614-
- DRIVERS_ATLAS_PUBLIC_API_KEY
615-
- DRIVERS_ATLAS_PRIVATE_API_KEY
616-
- DRIVERS_ATLAS_GROUP_ID
617621
- CLUSTER_NAME
618622
args:
623+
- .evergreen/with-secrets.sh
624+
- drivers/atlas-dev
619625
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
620626
setup_group_can_fail_task: true
621627
setup_group_timeout_secs: 1800

.evergreen/with-secrets.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
# This script takes an AWS Secrets Manager vault name and a command line
4+
# to execute, e.g.
5+
#
6+
# ./with-secrets drivers/atlas-dev setup-atlas-cluster.sh
7+
#
8+
# It fetches the secrets from the vault, populates the local environment
9+
# variables with those secrets, and then executes the command line.
10+
#
11+
# Secrets are cached based on the name of the vault, so if an earlier
12+
# task has fetched the same vault those secrets will be reused.
13+
14+
vault=$1
15+
shift
16+
17+
if [ -z "${vault}" ] || [ -z "$@" ]; then
18+
echo "At least two arguments (vault name and command) are required."
19+
exit 1
20+
fi
21+
22+
vault_cache_key=$(echo "${vault}" | sed -e s/\\\//_/)
23+
vault_cache_file="secrets-${vault_cache_key}.sh"
24+
25+
if [ -f "${vault_cache_file}" ]; then
26+
# Cached, hooray
27+
. "${vault_cache_file}"
28+
else
29+
# Need to actually fetch from the vault
30+
if [ -z "${DRIVERS_TOOLS}" ]; then
31+
echo "\$DRIVERS_TOOLS must be set."
32+
exit 1
33+
fi
34+
. "${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh" "${vault}"
35+
mv secrets-export.sh "${vault_cache_file}"
36+
fi
37+
38+
exec "$@"

0 commit comments

Comments
 (0)