def get_stage_actions()

in infra/src/stages/train_stage_codebuild_long_polling.py [0:0]


    def get_stage_actions(self, scope: core.Construct, env: str, stage_name: str,
                          source_artifacts: List[Artifact]) -> (StageActionList, VariableNamespace):
        self._set_common_params(scope)

        role, service_role = self.environment_specific_params(scope, env, stage_name)
        data_uri = self._cfn_data_uri_file_parameter.value_as_string

        code_build_variables_namespace = "{}{}Variables".format(env, stage_name)

        # Provide standard environment variables
        # Most tasks will need role to switch to, the data uri and the service role
        train_env_variables = {"SERVICE_ROLE_TO_ASSUME": aws_codebuild.BuildEnvironmentVariable(value=service_role,
                                                                                                type=aws_codebuild.BuildEnvironmentVariableType.PLAINTEXT),
                               "DATA_URI": aws_codebuild.BuildEnvironmentVariable(value=data_uri,
                                                                                  type=aws_codebuild.BuildEnvironmentVariableType.PLAINTEXT),
                               "ROLE_TO_ASSUME": aws_codebuild.BuildEnvironmentVariable(value=role,
                                                                                        type=aws_codebuild.BuildEnvironmentVariableType.PLAINTEXT)}
        # Provide standard environment variables
        # Most tasks will need role to switch to, the data uri and the service role
        build_project = self._code_build

        # Provide switch role
        assume_role_statement = 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))

        # Polling
        handler = self._handler
        handler.add_to_role_policy(assume_role_statement)

        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=code_build_variables_namespace,
                                                   environment_variables=train_env_variables)

        lambda_action = actions.LambdaInvokeAction(
            action_name="PollStatus{}".format(stage_name),
            lambda_=handler,
            run_order=2,
            user_parameters={
                "training_job_name": "#{{{}.{}}}".format(code_build_variables_namespace, TRAINING_JOB_NAME),
                "training_job_version": "#{{{}.{}}}".format(
                    code_build_variables_namespace, TRAINING_JOB_VERSION),
                "training_type": "#{{{}.{}}}".format(code_build_variables_namespace, TRAINING_JOB_TYPE),
                "assume_role": role
            }

        )

        return [codebuild_action, lambda_action], code_build_variables_namespace