I have a typescript CDK package where I need to upload a directory to S3 - I'd like the directory to be zipped up by the CDK code - is there any way to specify the directory should be zipped in the BucketDeployment
before uploading to S3?
new s3Deploy.BucketDeployment(this, 'bucket-code-deployment', {
sources: [s3Deploy.Source.asset('../infra/lambdas/lambda/directory')],
destinationBucket: lambdaCodeBucket,
});
Yes, you can zip a directory using the Asset class
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3_assets.Asset.html
const bundle = new Asset(this, 'bundle', {
path: 'src/resources/dockerExample',
});
An example of it being used here: https://subaud.io/blog/cdk-deployment-of-docker-image-with-codebuild