-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cli] Change sets that consist only of removalPolicy
changes cannot be executed
#11521
Comments
This seems to be caused by the fact CloudFormation treats change sets that consist only of changes to the removal policy as empty change sets, causing our CLI to execute them. aws-cdk/packages/aws-cdk/lib/api/deploy-stack.ts Lines 265 to 268 in e0c95fd
|
removalPolicy
changes cannot be executed
This is unfortunately unfixable on our end. @jerry-aws assume this behavior cannot be changed. How bad are the implications of that? |
@rix0rrr - yeah, i think the least we can do though is make But honestly if there are various scenarios with these "empty" change sets that we are not applying, we might need to reconsider this optimization, and just execute the change set regardless. |
We do this on purpose to avoid a CloudFormation I guess a potential way around it would be: record whether we THINK the change set is going to be empty, try the Or something to that effect. But this check is not merely a speed optimization like the "skip deploy" feature is: it's definitely to work around a kind of CFN behavior. |
Is this because we have no way of detecting this scenario from the failure message of |
I don't remember. It might just be us not wanting to issue a failing command. |
But we already issue a failing |
Research: It's not the addition of an
|
When changing just the removalpolicy, change set looks like this:
Execute leads to:
So it definitely will not execute. |
Behavior is the same if you add a |
Is it feasible to deploy some kind of no-op change (like setting a property to its current value) along with the problematic change in this situation, assuming the situation can be detected? Or are CloudFormation changes that don't actually change anything invalid? |
I just ran into this myself. Is there any hope for fixing this, or at least a workaround with some sort of no-op change? |
You need to make the no-op change yourself unfortunately |
Is there a clever no-op that I could blindly use on any resource type? Or do I have to figure out a no-op change for each type of resource I'm dealing with? |
Add a WaitConditionHandle. Doesn’t do or cost anything, but does change the template |
I was able to force a deployment by using:
This removes the |
I reached out to support about this and they mentioned that there's an internal feature request ("Add support for policy change through ChangeSets") that has been opened and accepted by the CloudFormation team. Maybe the CDK team could add their +1 internally to help move that along (cc @rix0rrr)? |
Related to #15065 |
If the only change to an
s3.Bucket
object that's already been deployed is to change itsremovalPolicy
, that change appears incdk diff
, butcdk deploy
says(no changes)
for that stack, and the change is not made to the bucket.If you deploy another change, such as to the
versioned
property, along with theremovalPolicy
change, the change toremovalPolicy
is made.This broke the "Your First AWS CDK app" topic in the developer guide, which updated the
removalPolicy
to allowcdk destroy
to delete the bucket. The user could still complete the tutorial, but the bucket would remain when it should have been deleted. (I have updated this topic to make an additional change with theremovalPolicy
one, which has the added benefit of showing an IAM policy in the diff, which has the side effect of deploying theremovalPolicy
change.)Unmodified version of this topic can be seen here: http://jkindall.aka.corp.amazon.com/snapshot/1605908585/hello_world.html
Reproduction Steps
Edit lib/hello-cdk-stack.ts to read:
Then:
Uncomment the
removalPolicy
definiiton.Save, build, and
cdk diff
. Note that the change to the removal policy appears in the diff output.Now
cdk deploy
and note that it saysHelloCdkStack (no changes)
. Anothercdk diff
will reveal that there's still a difference between the new synthesized template and the deployed one, indicating the change toremovalPolicy
was not deployed.Finally change
versioned
totrue
, thencdk deploy
and watch both changes be deployed.cdk diff
afterward to be sure.Environment
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: