in infra/src/stages/deploy_stage_codebuild.py [0:0]
def get_stage_actions(self, scope: core.Construct, env: str, stage_name: str, source_artifacts: List[Artifact],
train_job_output_variables: List[str], train_job_namespace: VariableNamespace) -> (
StageActionList, VariableNamespace):
service_role, role = self._environment_specific_params(scope, env, stage_name)
self._set_common_params(scope)
env_variables = {}
for v in train_job_output_variables:
env_variables[v] = aws_codebuild.BuildEnvironmentVariable(value="#{{{}.{}}}".format(train_job_namespace, v),
type=aws_codebuild.BuildEnvironmentVariableType.PLAINTEXT)
env_variables["ROLE_TO_ASSUME"] = aws_codebuild.BuildEnvironmentVariable(value=role,
type=aws_codebuild.BuildEnvironmentVariableType.PLAINTEXT)
stage_variable_namespace = "{}{}Variable".format(env, stage_name)
build_project = self._code_build
# Provide switch role
assume_role_statement = aws_iam.PolicyStatement(actions=["sts:AssumeRole"], resources=[role])
build_project.add_to_role_policy(assume_role_statement)
build_artifact = aws_codepipeline.Artifact("{}{}Artifacts".format(env, stage_name))
# Include output from the training job as input to the deploy
codebuild_action = actions.CodeBuildAction(outputs=[build_artifact],
action_name=f"{env}{stage_name}",
project=build_project,
input=source_artifacts[0],
type=actions.CodeBuildActionType.BUILD,
run_order=1,
# role=build_project.role,
variables_namespace=stage_variable_namespace,
environment_variables=env_variables)
return [codebuild_action], stage_variable_namespace