CodeBuildOptions

class aws_cdk.pipelines.CodeBuildOptions(*, build_environment=None, partial_build_spec=None, role_policy=None, security_groups=None, subnet_selection=None, timeout=None, vpc=None)

Bases: object

Options for customizing a single CodeBuild project.

Parameters
  • build_environment (Union[BuildEnvironment, Dict[str, Any], None]) – Partial build environment, will be combined with other build environments that apply. Default: - Non-privileged build, SMALL instance, LinuxBuildImage.STANDARD_5_0

  • partial_build_spec (Optional[BuildSpec]) – Partial buildspec, will be combined with other buildspecs that apply. The BuildSpec must be available inline–it cannot reference a file on disk. Default: - No initial BuildSpec

  • role_policy (Optional[Sequence[PolicyStatement]]) – Policy statements to add to role. Default: - No policy statements added to CodeBuild Project Role

  • security_groups (Optional[Sequence[ISecurityGroup]]) – Which security group(s) to associate with the project network interfaces. 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 create the CodeBuild network interfaces in. Default: - No VPC

ExampleMetadata

infused

Example:

# vpc: ec2.Vpc
# my_security_group: ec2.SecurityGroup

pipelines.CodePipeline(self, "Pipeline",
    # Standard CodePipeline properties
    synth=pipelines.ShellStep("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"
        ]
    ),

    # Defaults for all CodeBuild projects
    code_build_defaults=pipelines.CodeBuildOptions(
        # Prepend commands and configuration to all projects
        partial_build_spec=codebuild.BuildSpec.from_object({
            "version": "0.2"
        }),

        # Control the build environment
        build_environment=codebuild.BuildEnvironment(
            compute_type=codebuild.ComputeType.LARGE
        ),

        # Control Elastic Network Interface creation
        vpc=vpc,
        subnet_selection=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PRIVATE_WITH_NAT),
        security_groups=[my_security_group],

        # Additional policy statements for the execution role
        role_policy=[
            iam.PolicyStatement()
        ]
    ),

    synth_code_build_defaults=pipelines.CodeBuildOptions(),
    asset_publishing_code_build_defaults=pipelines.CodeBuildOptions(),
    self_mutation_code_build_defaults=pipelines.CodeBuildOptions()
)

Attributes

build_environment

Partial build environment, will be combined with other build environments that apply.

Default
  • Non-privileged build, SMALL instance, LinuxBuildImage.STANDARD_5_0

Return type

Optional[BuildEnvironment]

partial_build_spec

Partial buildspec, will be combined with other buildspecs that apply.

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

Default
  • No initial BuildSpec

Return type

Optional[BuildSpec]

role_policy

Policy statements to add to role.

Default
  • No policy statements added to CodeBuild Project Role

Return type

Optional[List[PolicyStatement]]

security_groups

Which security group(s) to associate with the project network interfaces.

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 create the CodeBuild network interfaces in.

Default
  • No VPC

Return type

Optional[IVpc]