Cache

class aws_cdk.aws_codebuild.Cache

Bases: object

Cache options for CodeBuild Project.

A cache can store reusable pieces of your build environment and use them across multiple builds.

See:

https://docs.aws.amazon.com/codebuild/latest/userguide/build-caching.html

ExampleMetadata:

infused

Example:

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

pipelines.CodeBuildStep("Synth",
    # ...standard ShellStep props...
    commands=[],
    env={},

    # If you are using a CodeBuildStep explicitly, set the 'cdk.out' directory
    # to be the synth step's output.
    primary_output_directory="cdk.out",

    # Control the name of the project
    project_name="MyProject",

    # Control parts of the BuildSpec other than the regular 'build' and 'install' commands
    partial_build_spec=codebuild.BuildSpec.from_object({
        "version": "0.2"
    }),

    # Control the build environment
    build_environment=codebuild.BuildEnvironment(
        compute_type=codebuild.ComputeType.LARGE,
        privileged=True
    ),
    timeout=Duration.minutes(90),
    file_system_locations=[
        codebuild.FileSystemLocation.efs(
            identifier="myidentifier2",
            location="myclodation.mydnsroot.com:/loc",
            mount_point="/media",
            mount_options="opts"
        )
    ],

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

    # Control caching
    cache=codebuild.Cache.bucket(s3.Bucket(self, "Cache")),

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

Static Methods

classmethod bucket(bucket, *, cache_namespace=None, prefix=None)

Create an S3 caching strategy.

Parameters:
  • bucket (IBucket) – the S3 bucket to use for caching.

  • cache_namespace (Optional[str]) – Defines the scope of the cache. You can use this namespace to share a cache across multiple projects. Default: undefined - No cache namespace, which means that the cache is not shared across multiple projects.

  • prefix (Optional[str]) – The prefix to use to store the cache in the bucket.

Return type:

Cache

classmethod local(*modes)

Create a local caching strategy.

Parameters:

modes (LocalCacheMode) – the mode(s) to enable for local caching.

Return type:

Cache

classmethod none()
Return type:

Cache