55from config_generator .etc .utils import bash_exec
66
77from shrub .v3 .evg_build_variant import BuildVariant
8- from shrub .v3 .evg_command import BuiltInCommand , EvgCommandType , ec2_assume_role , expansions_update , s3_put
8+ from shrub .v3 .evg_command import (
9+ BuiltInCommand ,
10+ EvgCommandType ,
11+ KeyValueParam ,
12+ ec2_assume_role ,
13+ expansions_update ,
14+ s3_put ,
15+ )
916from shrub .v3 .evg_task import EvgTask , EvgTaskRef
1017
1118from pydantic import ConfigDict
12- from typing import Optional
1319
1420
1521TAG = 'sbom'
@@ -23,31 +29,50 @@ class CustomCommand(BuiltInCommand):
2329class CheckAugmentedSBOM (Function ):
2430 name = 'check augmented sbom'
2531 commands = [
26- ec2_assume_role (
27- command_type = EvgCommandType .SETUP ,
28- role_arn = '${KONDUKTO_ROLE_ARN}' ,
29- ),
30- bash_exec (
31- command_type = EvgCommandType .SETUP ,
32- include_expansions_in_env = ['AWS_ACCESS_KEY_ID' , 'AWS_SECRET_ACCESS_KEY' , 'AWS_SESSION_TOKEN' ],
33- script = '''\
34- set -o errexit
35- set -o pipefail
36- kondukto_token="$(aws secretsmanager get-secret-value --secret-id "kondukto-token" --region "us-east-1" --query 'SecretString' --output text)"
37- printf "KONDUKTO_TOKEN: %s\\ n" "$kondukto_token" >|expansions.kondukto.yml
38- ''' ,
39- ),
40- expansions_update (
41- command_type = EvgCommandType .SETUP ,
42- file = 'expansions.kondukto.yml' ,
43- ),
32+ # Authenticate with Kondukto.
33+ * [
34+ ec2_assume_role (
35+ command_type = EvgCommandType .SETUP ,
36+ role_arn = '${KONDUKTO_ROLE_ARN}' ,
37+ ),
38+ bash_exec (
39+ command_type = EvgCommandType .SETUP ,
40+ include_expansions_in_env = ['AWS_ACCESS_KEY_ID' , 'AWS_SECRET_ACCESS_KEY' , 'AWS_SESSION_TOKEN' ],
41+ script = '''\
42+ set -o errexit
43+ set -o pipefail
44+ kondukto_token="$(aws secretsmanager get-secret-value --secret-id "kondukto-token" --region "us-east-1" --query 'SecretString' --output text)"
45+ printf "KONDUKTO_TOKEN: %s\\ n" "$kondukto_token" >|expansions.kondukto.yml
46+ ''' ,
47+ ),
48+ expansions_update (
49+ command_type = EvgCommandType .SETUP ,
50+ file = 'expansions.kondukto.yml' ,
51+ ),
52+ ],
53+ # Authenticate with Amazon ECR.
54+ * [
55+ # Avoid inadvertently using a pre-existing and potentially conflicting Docker config.
56+ # Note: podman understands and uses DOCKER_CONFIG despite the name.
57+ expansions_update (updates = [KeyValueParam (key = 'DOCKER_CONFIG' , value = '${workdir}/.docker' )]),
58+ ec2_assume_role (role_arn = 'arn:aws:iam::901841024863:role/ecr-role-evergreen-ro' ),
59+ bash_exec (
60+ command_type = EvgCommandType .SETUP ,
61+ include_expansions_in_env = [
62+ 'AWS_ACCESS_KEY_ID' ,
63+ 'AWS_SECRET_ACCESS_KEY' ,
64+ 'AWS_SESSION_TOKEN' ,
65+ 'DOCKER_CONFIG' ,
66+ ],
67+ script = 'aws ecr get-login-password --region us-east-1 | podman login --username AWS --password-stdin 901841024863.dkr.ecr.us-east-1.amazonaws.com' ,
68+ ),
69+ ],
4470 bash_exec (
4571 command_type = EvgCommandType .TEST ,
4672 working_dir = 'mongo-cxx-driver' ,
4773 include_expansions_in_env = [
48- 'ARTIFACTORY_PASSWORD' ,
49- 'ARTIFACTORY_USER' ,
5074 'branch_name' ,
75+ 'DOCKER_CONFIG' ,
5176 'KONDUKTO_TOKEN' ,
5277 ],
5378 script = '.evergreen/scripts/sbom.sh' ,
0 commit comments