Closed jglesner closed 2 years ago
Appears as though if you change the context to 'this' when creating the bucket -e.g. new s3.Bucket(this, "CacheBucket")
instead of using 'scope', it works as expected. Full example like so:
const myCachingBucket = new s3.Bucket(this, "CacheBucket", {
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
encryption: s3.BucketEncryption.S3_MANAGED,
enforceSSL: true,
versioned: true,
removalPolicy: cdk.RemovalPolicy.RETAIN,
});
const pipeline = new CodePipeline(this, "Pipeline", {
pipelineName: "ServerlessPipeline",
crossAccountKeys: true,
dockerEnabledForSelfMutation: true,
dockerEnabledForSynth: true,
synth: new ShellStep("Synth", {
input: CodePipelineSource.codeCommit(pipelineRepo, "master"),
commands: ["npm ci", "npm run build", "npx cdk synth"],
}),
codeBuildDefaults: {
cache: codebuild.Cache.bucket(myCachingBucket),
buildEnvironment: {
privileged: true,
computeType: codebuild.ComputeType.MEDIUM,
},
},
});
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Describe the bug
Trying to use the 'cache' property of CodeBuildOptions with 'codeBuildDefaults' property of 'CodePipelineProps'. In the linked documentation, specifically for Cache, this looks like a valid implementation.
Receiving the below CDK error, running AWS CDK 2.38.1 when trying to create the bucket for caching
Assume this mean I can't setup 'cache' when initially instantiating the CodePipeline, and I have to add it after setting up the bucket in a stack? But that seems odd / kludgy in some respects. Is this intended behavior?
Expected Behavior
Given that 'cache' is an option for CodeBuildOptions, I would expect cache to be configurable with an S3 bucket when first defining the CodePipeline.
Current Behavior
It fails as shown in the included error message.
Reproduction Steps
As shown in the included 'CodePipeline' setup.
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.38.1
Framework Version
2.38.1
Node.js Version
14.17.0
OS
OS X Monterey 12.1
Language
Typescript
Language Version
3.9.7
Other information
No response