smallbirds
smallbirds

Reputation: 1087

Deploying CDK Stack from cdk.out folder on S3 bucket (AWS)

I would like to know if its possible to do something like this:

  1. Do a CDK synth locally which will create a cdk.out folder (it should have all the required files for a cdk deploy?)
  2. Upload the cdk.out folder to a S3 bucket
  3. Do a CDK deployment based on the content of the cdk.out folder in S3 using "cdk deploy" in CodeBuild

I can manage to do those three steps if I upload the full CDK project including typescript files to the S3 bucket. So my question is if there is a workaround so you only need the cdk.out folder and not the typescript scripts themselves. I mean the project has already been synthesized?

When I try to do it from cdk.out folder, it complains about needing the cdk.json file. If i upload that file with the cdk.out folder, it compains about not finding the typescript files. I think its because i do have an "app": "npx ts-node bin/app.ts" in cdk.json. I am not sure how to go about this and if its even possible.

If it is not possible, i will just have to upload the full project and not only the cdk.out folder...

Upvotes: 4

Views: 5688

Answers (1)

smallbirds
smallbirds

Reputation: 1087

I figured out that I can get it to work by using

cdk deploy --app 'cdk.out/' <my-stack>

Then it will refer to the CDK assets in cdk.out and build from there, so there is no need to upload all the files and do a "cdk synth" all over again

Upvotes: 8

Related Questions