Reputation: 1432
I am using BitBucket pipelines to deploy an app to AWS using the Python CDK. As part of the process the cloud assembly cdk.out
directory is created as documents in the AWS docs.
I am wondering if there is any benefit in caching this directory so that it's reused between pipeline runs, just like we cache pip
dependencies for example, or just let it be created from scratch on every pipeline run.
Upvotes: 3
Views: 7265
Reputation: 11
Assets for lambdas are built based on a hash of the source directory for that lambda. So if you copy in your cdk.out even if you are building on a new commit. It will be able to reuse some of those asset files without having to rebuild them.
Be careful doing this if you have a side affecting build process that uses data outside of the lambdas source directory as these side effects wont be reflected in the hash and as such won't force the asset to be rebuilt.
I found this out the hard way when I was local Bundling using a script and passing in some python packages names as in input to my custom script. Since the source folders for layers were all the same (empty) it just reused the same asset for all of them, even though the script itself would have made completely different files!
Upvotes: 1
Reputation: 25679
cdk deploy
synthesizes the CloudAssembly artifacts into cdk.out
each time before deploying. Caching wouldn't help there.
However, the CDK apparently caches zipped artifacts (before uploading to S3), so in theory you could save .zip
-ing time by caching cdk.out/.cache
.
Upvotes: 2