Search code examples
amazon-web-servicesaws-cdkcicd

How many times do I need to run cdk bookstrap?


I am trying to understand how cdk bootstrap works. I have read the doc: https://github.com/aws/aws-cdk/blob/master/design/cdk-bootstrap.md and tried to run the command in my AWS account. I can see a new cf stack is created CDKToolkit which includes s3 bucket, iam roles etc.

My question is whether I need to run this command for every cdk project I have? Or is it just one time execution? If I have projects using different cdk version v1 and v2, do I use the same cf stack? Will it cause version conflicts?


Solution

  • It's typically a one time thing per account per region. The infrastructure in that stack is shared among your CDK apps.

    There was a change in format a while ago that required an update of the stack, but since then it has remained largely unchanged.

    The docs on bootstrap are probably more helpful than the Github Link: CDK Bootstrapping.

    Each CloudFormation stack created by a CDK app only belongs to one CDK app, they shouldn't be shared. The outputs can be referenced from other apps, but each stack should belong to one app.

    That's why you can mix and match CDK versions across different stacks. Usually each CDK app maps to one or more CloudFormation stacks.