Reputation: 996
A few months ago I played around with AWS CDK and so I of course did the cdk bootstrap
.
At that time I stopped playing around and thought I'd never use it again. Having a kind of neatly attitude in this kind of things (and missing an undo or delete option being delivered with the cdk itself :/ ) I deleted all cdk objects from my account.
Or at least I thought so, because now (starting to play around again), calling cdk bootstrap
does "nothing":
✅ Environment aws://xxxxxxxxx/eu-central-1 bootstrapped (no changes).
But trying to cdk deploy
gives me:
fail: No bucket named 'cdk-XXXXXXXXXXX-eu-central-1'. Is account XXXXXXXXXXXX bootstrapped?
Well yes right...I don't have any buckets at all at the moment.
Is there a way to cdk bootstrap --force
that I'am missing? Is there a list of all objects I should have deleted? I find a lot suggestions for people having problems with their stacks, but I have no idea how to fix this.
Edit: I just "solved" the problem, by creating a bucket with the given cryptic name...but that doesn't feel right. So I leave this Question open, to see if there is a better way to do it.
Upvotes: 11
Views: 5996
Reputation: 5145
I hope this helps future googlers:
cdk bootstrap --trust=$ACCOUNT_ID \
--cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess \
aws://$ACCOUNT_ID/us-west-2 \
aws://$ACCOUNT_ID/us-east-2 \
aws://$ACCOUNT_ID/us-east-1
I ran the above as part of the eks-blueprints-cdk-workshop, (the self paced one), and had a ton of trouble with it, because deleting the s3 bucket & CloudFormat Stack wasn't correctly resetting the initial state.
By trouble I mean it'd bootstrap 2 of 3 regions, and then say the 3rd had already been bootstrapped which I knew had to be incorrect since this was my 1st time doing the lab. I then followed the accepted answer to try to fix it, but upon retrying it said only 1 of 3 regions would bootstrap.
That's when I remembered that:
CloudFormation stacks are a regional resource. So if you still have trouble getting back to a fresh state after following the above, double-check your regions / that you don't have CDKToolkit deployed to multiple regions and that you're removing it from the correct region / all relevant regions.
(I now realize that the cause of this was me forgetting to fully and completely clean up my environment after following a different how to guide.)
Once I deleted the CDKToolkit
CF Stack from the 3 regions mentioned in the above command, and then re-ran the above cdk bootstrap command it finally worked as expected. Makes perfect sense in retrospect, but it didn't immediately occur to me that CF stacks are regional resources, since I tend to stay away from CF stacks in general in favor of higher level abstractions.
Upvotes: 0
Reputation: 25739
Bootstrapping creates a Stack called CDKToolkit
, which has the CloudFormation resources CDK needs to deploy. You can safely "uninstall-reinstall" it:
aws cloudformation delete-stack --stack-name CDKToolkit
cdk bootstrap
Note: "Drift" is the technical term for your problem. The actual AWS resource state "drifted" from the expected state defined in the CDKToolkit
CloudFormation template. CloudFormation has tools to deal with the drift problem. You can report on drift, for instance:
aws cloudformation detect-stack-drift --stack-name CDKToolkit
Upvotes: 23