Skip to content

cdk.pipelines - Allow the configuration of Caching properties for Synth CodebuildProject  #16375

@mrpackethead

Description

@mrpackethead

It would be helpful to add the abillity to set caching for the synth code build project in a pipeline. This will help with speed up the build and run times of pipelines. I have achived the desired result by using escape hatches but this is not particaully elegent and could be improved with some minor work.

if 'SynthProjectCachePropertys' in synth_cfg.keys():

            # the pipeline needs to be built bfore you can extract the synth
            # codebuild project. 
            # Everything needs to be done with buildingpipeline prior to this, 
            # as you can't modify it after you build. s
            pipeline.build_pipeline()

            codebuild_cache_bucket = s3.Bucket(self, 'codebuild_cache_bucket',
                auto_delete_objects= True,
                removal_policy= cdk.RemovalPolicy.DESTROY,
                block_public_access= s3.BlockPublicAccess.BLOCK_ALL
            )

            # finally use an escape hatch to manipulate the codebuild
            SynthCodeBuildProject: codebuild.CfnProject = pipeline.synth_project.node.default_child
            SynthCodeBuildProject.ProjectCacheProperty(
                type="S3",
                location = codebuild_cache_bucket.bucket_name,
                modes = synth_cfg['SynthProjectCachePropertys']['modes'],
            )
            # allow the code build project permission.
            codebuild_cache_bucket.grant_read_write(SynthCodeBuildProject)

### Use Case

Speed up the pipeline time. 



Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/pipelinesCDK Pipelines libraryeffort/mediumMedium work item – several days of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions