aws-cdk-lib.aws_codebuild.Cache

class Cache

LanguageType name
.NETAmazon.CDK.AWS.CodeBuild.Cache
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscodebuild#Cache
Javasoftware.amazon.awscdk.services.codebuild.Cache
Pythonaws_cdk.aws_codebuild.Cache
TypeScript (source)aws-cdk-lib » aws_codebuild » Cache

Cache options for CodeBuild Project.

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

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

Example

declare const myCachingBucket: s3.Bucket;

new codebuild.Project(this, 'Project', {
  source: codebuild.Source.bitBucket({
    owner: 'awslabs',
    repo: 'aws-cdk',
  }),

  cache: codebuild.Cache.bucket(myCachingBucket),

  // BuildSpec with a 'cache' section necessary for S3 caching. This can
  // also come from 'buildspec.yml' in your source.
  buildSpec: codebuild.BuildSpec.fromObject({
    version: '0.2',
    phases: {
      build: {
        commands: ['...'],
      },
    },
    cache: {
      paths: [
        // The '**/*' is required to indicate all files in this directory
        '/root/cachedir/**/*',
      ],
    },
  }),
});

Initializer

new Cache()

Methods

NameDescription
static bucket(bucket, options?)Create an S3 caching strategy.
static local(...modes)Create a local caching strategy.
static none()

static bucket(bucket, options?)

public static bucket(bucket: IBucket, options?: BucketCacheOptions): Cache

Parameters

  • bucket IBucket — the S3 bucket to use for caching.
  • options BucketCacheOptions — additional options to pass to the S3 caching.

Returns

  • Cache

Create an S3 caching strategy.


static local(...modes)

public static local(...modes: LocalCacheMode[]): Cache

Parameters

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

Returns

  • Cache

Create a local caching strategy.


static none()

public static none(): Cache

Returns

  • Cache