2개 답변
- 최신
- 최다 투표
- 가장 많은 댓글
1
I assume you are attempting to modify the lifecycle policy of the underlying S3 Artifacts bucket of your CDK pipeline. At the time of writing, there is no direct way to do this.
The workaround is to pass in an existing codePipeline as an input to your CDK pipeline. In turn, you can pass in an artifactBucket to this CodePipeline. Since you would be creating your own S3 bucket in this case, you would have full control over every aspect of it, including its lifecycle policy.
In Python for example:
artifact_bucket = Bucket(
self,
"code-pipeline-bucket",
) # Since you would be managing the bucket, you can set its properties like the lifecycle policy
code_pipeline = Pipeline(
self,
"code-pipeline",
artifact_bucket=artifact_bucket, # Pass in the Bucket
...
)
cdk_pipeline = CodePipeline(
self,
"cdk-pipeline",
code_pipeline=code_pipeline, # Pass in the CodePipeline
...
)
답변함 2년 전
0
Thank you! This worked.
For anyone reading this in the future, this is what I did:
class Pipeline extends cdk.Stack { constructor(scope: Construct){ super(scope, id, props) const pipeline = new pipelines.CodePipeline(this, 'App', { codePipeline: this.buildPipeline(), ...Other config }) } private buildPipeline(): codepipeline.Pipeline { const artifactBucket = new s3.Bucket(this, 'ArtifactBucket') /** * https://github.com/aws/aws-cdk/blob/0ed661df0b060d0ec4c502b92511b3e777144854/packages/%40aws-cdk/pipelines/lib/codepipeline/codepipeline.ts#L348 */ const pipeline = new codepipeline.Pipeline(this, 'Pipeline', { /** * This is necessary to make self-mutation work * (deployments are guaranteed to happen only * after the builds of the latest pipeline * definition). */ restartExecutionOnUpdate: true, artifactBucket, }) return pipeline }
답변함 2년 전