@@ -23,6 +23,7 @@ Options
2323 -V, --version -- Print the SDLF version
2424 -h, --help -- Show this help message
2525 -p -- Name of the AWS profile to use
26+ -b -- AWS account ID of the CodeBuild project
2627 -c -- Name of the SDLF construct that will be used
2728 <name> -- Name to uniquely identify this deployment
2829
@@ -149,6 +150,15 @@ if ! "$bflag"
149150then
150151 echo " CodeBuild project is assumed to be in the same AWS account" >&2
151152 CODEBUILD_ACCOUNT_ID=$( aws sts get-caller-identity --query Account --output text ${REGION: +--region " $REGION " } ${PROFILE: +--profile " $PROFILE " } )
153+
154+ CODEBUILD_ROLE=$( aws codebuild batch-get-projects --names " sdlf-cicd-$1 " --query " projects[0].serviceRole" --output text ${REGION: +--region " $REGION " } ${PROFILE: +--profile " $PROFILE " } | cut -d' /' -f2)
155+ CODEBUILD_ROLE_BOOTSTRAP=$( aws codebuild batch-get-projects --names " sdlf-cicd-bootstrap" --query " projects[0].serviceRole" --output text ${REGION: +--region " $REGION " } ${PROFILE: +--profile " $PROFILE " } | cut -d' /' -f2)
156+ else
157+ if [ -z ${2+x} ]; then die ' ERROR: "./deploy-role.sh" requires a second non-option argument providing the CodeBuild project IAM role name.' ; fi
158+ if [ -z ${3+x} ]; then die ' ERROR: "./deploy-role.sh" requires a third non-option argument providing the boostrap CodeBuild project IAM role name.' ; fi
159+
160+ CODEBUILD_ROLE=$2
161+ CODEBUILD_ROLE_BOOTSTRAP=$3
152162fi
153163
154164STACK_NAME=" sdlf-cicd-role-$CODEBUILD_ACCOUNT_ID -$1 "
@@ -159,6 +169,8 @@ aws cloudformation deploy \
159169 --parameter-overrides \
160170 pCodeBuildAccountId=" $CODEBUILD_ACCOUNT_ID " \
161171 pCodeBuildSuffix=" $1 " \
172+ pCodeBuildBootstrapRole=" $CODEBUILD_ROLE_BOOTSTRAP " \
173+ pCodeBuildUserRepositoryRole=" $CODEBUILD_ROLE " \
162174 --tags Framework=sdlf \
163175 --capabilities " CAPABILITY_NAMED_IAM" " CAPABILITY_AUTO_EXPAND" \
164176 ${REGION: +--region " $REGION " } \
0 commit comments