CodeBuildStepProps

class aws_cdk.pipelines.CodeBuildStepProps(*, commands, additional_inputs=None, env=None, env_from_cfn_outputs=None, input=None, install_commands=None, primary_output_directory=None, action_role=None, build_environment=None, partial_build_spec=None, project_name=None, role=None, role_policy_statements=None, security_groups=None, subnet_selection=None, timeout=None, vpc=None)

Bases: ShellStepProps

Construction props for a CodeBuildStep.

Parameters
  • commands (Sequence[str]) – Commands to run.

  • additional_inputs (Optional[Mapping[str, IFileSetProducer]]) – Additional FileSets to put in other directories. Specifies a mapping from directory name to FileSets. During the script execution, the FileSets will be available in the directories indicated. The directory names may be relative. For example, you can put the main input and an additional input side-by-side with the following configuration:: const script = new pipelines.ShellStep(‘MainScript’, { commands: [‘npm ci’,’npm run build’,’npx cdk synth’], input: pipelines.CodePipelineSource.gitHub(‘org/source1’, ‘main’), additionalInputs: { ‘../siblingdir’: pipelines.CodePipelineSource.gitHub(‘org/source2’, ‘main’), } }); Default: - No additional inputs

  • env (Optional[Mapping[str, str]]) – Environment variables to set. Default: - No environment variables

  • env_from_cfn_outputs (Optional[Mapping[str, CfnOutput]]) – Set environment variables based on Stack Outputs. ``ShellStep``s following stack or stage deployments may access the ``CfnOutput``s of those stacks to get access to –for example–automatically generated resource names or endpoint URLs. Default: - No environment variables created from stack outputs

  • input (Optional[IFileSetProducer]) – FileSet to run these scripts on. The files in the FileSet will be placed in the working directory when the script is executed. Use additionalInputs to download file sets to other directories as well. Default: - No input specified

  • install_commands (Optional[Sequence[str]]) – Installation commands to run before the regular commands. For deployment engines that support it, install commands will be classified differently in the job history from the regular commands. Default: - No installation commands

  • primary_output_directory (Optional[str]) – The directory that will contain the primary output fileset. After running the script, the contents of the given directory will be treated as the primary output of this Step. Default: - No primary output

  • action_role (Optional[IRole]) – Custom execution role to be used for the Code Build Action. Default: - A role is automatically created

  • build_environment (Union[BuildEnvironment, Dict[str, Any], None]) – Changes to environment. This environment will be combined with the pipeline’s default environment. Default: - Use the pipeline’s default build environment

  • partial_build_spec (Optional[BuildSpec]) – Additional configuration that can only be configured via BuildSpec. You should not use this to specify output artifacts; those should be supplied via the other properties of this class, otherwise CDK Pipelines won’t be able to inspect the artifacts. Set the commands to an empty array if you want to fully specify the BuildSpec using this field. The BuildSpec must be available inline–it cannot reference a file on disk. Default: - BuildSpec completely derived from other properties

  • project_name (Optional[str]) – Name for the generated CodeBuild project. Default: - Automatically generated

  • role (Optional[IRole]) – Custom execution role to be used for the CodeBuild project. Default: - A role is automatically created

  • role_policy_statements (Optional[Sequence[PolicyStatement]]) – Policy statements to add to role used during the synth. Can be used to add acces to a CodeArtifact repository etc. Default: - No policy statements added to CodeBuild Project Role

  • security_groups (Optional[Sequence[ISecurityGroup]]) – Which security group to associate with the script’s project network interfaces. If no security group is identified, one will be created automatically. Only used if ‘vpc’ is supplied. Default: - Security group will be automatically created.

  • subnet_selection (Union[SubnetSelection, Dict[str, Any], None]) – Which subnets to use. Only used if ‘vpc’ is supplied. Default: - All private subnets.

  • timeout (Optional[Duration]) – The number of minutes after which AWS CodeBuild stops the build if it’s not complete. For valid values, see the timeoutInMinutes field in the AWS CodeBuild User Guide. Default: Duration.hours(1)

  • vpc (Optional[IVpc]) – The VPC where to execute the SimpleSynth. Default: - No VPC

ExampleMetadata

infused

Example:

pipelines.CodePipeline(self, "Pipeline",
    synth=pipelines.CodeBuildStep("Synth",
        input=pipelines.CodePipelineSource.connection("my-org/my-app", "main",
            connection_arn="arn:aws:codestar-connections:us-east-1:222222222222:connection/7d2469ff-514a-4e4f-9003-5ca4a43cdc41"
        ),
        commands=["...", "npm ci", "npm run build", "npx cdk synth", "..."
        ],
        role_policy_statements=[
            iam.PolicyStatement(
                actions=["sts:AssumeRole"],
                resources=["*"],
                conditions={
                    "StringEquals": {
                        "iam:ResourceTag/aws-cdk:bootstrap-role": "lookup"
                    }
                }
            )
        ]
    )
)

Attributes

action_role

Custom execution role to be used for the Code Build Action.

Default
  • A role is automatically created

Return type

Optional[IRole]

additional_inputs

Additional FileSets to put in other directories.

Specifies a mapping from directory name to FileSets. During the script execution, the FileSets will be available in the directories indicated.

The directory names may be relative. For example, you can put the main input and an additional input side-by-side with the following configuration:

script = pipelines.ShellStep("MainScript",
    commands=["npm ci", "npm run build", "npx cdk synth"],
    input=pipelines.CodePipelineSource.git_hub("org/source1", "main"),
    additional_inputs={
        "../siblingdir": pipelines.CodePipelineSource.git_hub("org/source2", "main")
    }
)
Default
  • No additional inputs

Return type

Optional[Mapping[str, IFileSetProducer]]

build_environment

Changes to environment.

This environment will be combined with the pipeline’s default environment.

Default
  • Use the pipeline’s default build environment

Return type

Optional[BuildEnvironment]

commands

Commands to run.

Return type

List[str]

env

Environment variables to set.

Default
  • No environment variables

Return type

Optional[Mapping[str, str]]

env_from_cfn_outputs

Set environment variables based on Stack Outputs.

``ShellStep``s following stack or stage deployments may access the ``CfnOutput``s of those stacks to get access to –for example–automatically generated resource names or endpoint URLs.

Default
  • No environment variables created from stack outputs

Return type

Optional[Mapping[str, CfnOutput]]

input

FileSet to run these scripts on.

The files in the FileSet will be placed in the working directory when the script is executed. Use additionalInputs to download file sets to other directories as well.

Default
  • No input specified

Return type

Optional[IFileSetProducer]

install_commands

Installation commands to run before the regular commands.

For deployment engines that support it, install commands will be classified differently in the job history from the regular commands.

Default
  • No installation commands

Return type

Optional[List[str]]

partial_build_spec

Additional configuration that can only be configured via BuildSpec.

You should not use this to specify output artifacts; those should be supplied via the other properties of this class, otherwise CDK Pipelines won’t be able to inspect the artifacts.

Set the commands to an empty array if you want to fully specify the BuildSpec using this field.

The BuildSpec must be available inline–it cannot reference a file on disk.

Default
  • BuildSpec completely derived from other properties

Return type

Optional[BuildSpec]

primary_output_directory

The directory that will contain the primary output fileset.

After running the script, the contents of the given directory will be treated as the primary output of this Step.

Default
  • No primary output

Return type

Optional[str]

project_name

Name for the generated CodeBuild project.

Default
  • Automatically generated

Return type

Optional[str]

role

Custom execution role to be used for the CodeBuild project.

Default
  • A role is automatically created

Return type

Optional[IRole]

role_policy_statements

Policy statements to add to role used during the synth.

Can be used to add acces to a CodeArtifact repository etc.

Default
  • No policy statements added to CodeBuild Project Role

Return type

Optional[List[PolicyStatement]]

security_groups

Which security group to associate with the script’s project network interfaces.

If no security group is identified, one will be created automatically.

Only used if ‘vpc’ is supplied.

Default
  • Security group will be automatically created.

Return type

Optional[List[ISecurityGroup]]

subnet_selection

Which subnets to use.

Only used if ‘vpc’ is supplied.

Default
  • All private subnets.

Return type

Optional[SubnetSelection]

timeout

The number of minutes after which AWS CodeBuild stops the build if it’s not complete.

For valid values, see the timeoutInMinutes field in the AWS CodeBuild User Guide.

Default

Duration.hours(1)

Return type

Optional[Duration]

vpc

The VPC where to execute the SimpleSynth.

Default
  • No VPC

Return type

Optional[IVpc]