feat(autoscaling): add deletionProtection property to AutoScalingGroup#36924
feat(autoscaling): add deletionProtection property to AutoScalingGroup#36924mergify[bot] merged 19 commits intoaws:mainfrom
Conversation
…at/add-deletionProtection-to-asg
…at/add-deletionProtection-to-asg
…at/add-deletionProtection-to-asg
|
|
||||||||||||||
|
|
||||||||||||||
…at/add-deletionProtection-to-asg
|
Hey, thanks a lot for the pr. It looks solid. Just one question: is there any particular reason for the extensive integ testing? Normally I believe we dont need integ tests for just exposing an L1 property on an L2, the unit tests would be enough for me. If you want to test that the property is transferred, I think a test for a single value would be enough, maybe the none, since that wont prevent test cleanup. Also, you could just rename one of the other tests for a more generic name (e.g. integ.asg-capacity-rebalance.ts to integ.asg-capacity-properties.ts), and add this property there too. |
Pull request has been modified.
Thanks for the comment.
For me, comprehensive testing just makes me feel more confident to send PR.
That makes sense. |
|
I understand where you are coming from, and it makes totally sense. My main concern is, that this package now has tons of integ tests, which take ages to run, and because of that, they are never run, which renders them useless, since with time they stop working, and noone notices. We are spending effort to make the suit runnable again, and we need to balance out test coverage, with reasonable amount of tests. But if you already spent the effort, lets make the test explicit. I dont think we need all 3 integ test cases (that is a lot of resources and time - we need the 3 cases in unit tests only). There are examples for trying to delete the stack (/packages/@aws-cdk-testing/framework-integ/test/aws-cloudformation/test/integ.core-cross-region-references.ts). |
|
Thanks for advise ! |
…at/add-deletionProtection-to-asg
|
@matboros |
…at/add-deletionProtection-to-asg
|
Hi @matoom-nomu, im really sorry for the slow response. I really like your approach, and I especially liked the tries you did. You said:
I cannot find that code, how hacky is that? For the update stack, you said that updating through the cli is problematic, becuase it is missing parameters. I'd think, why dont we update the property in the stack, and regenerate the cfn template, and do a cfn deployment of the same stack? sounds more resilient, should work with old cli, tests that value can be updated through cdk/cfn. I like the update being in the predestroy hook, that communicates intent perfectly. What do you think about this? since you already had all the pieces, it should be simple to test, no? |
…at/add-deletionProtection-to-asg
|
Hi @matboros
Same opinion too. ① Update Cfn via This results in the stack being updated before the assertion runs: -> initial stack deploy So far, I haven’t found a way to perform the stack update after the assertion. ② Update the actual ASG via As I mentioned at comment at here Thus, updating deletionProtection after assertion appears to be difficult at the moment.
It’s turned out to be just a matter of stack dependencies. |
|
Hi @matoom-nomu,
-> initial stack deploy are you sure about step 2? i would assume, based on the code you wrote, that you are modifying the initial stack, so the initial stack will deploy DeletionProtection none, no? the actual runtime execution all happens afterwards. My tip would be (without having tried): const stackName = "aws-cdk-autoscaling-deletion-protection";
const asgStack = new cdk.Stack(app, stackName);
const asg = new autoscaling.AutoScalingGroup(asgStack, 'FleetPreventAll' ・・・
// assertion logic
test.assertions.awsApiCall('CloudFormation', 'deleteStack', {
StackName: stackName,
})
// get the template you will use for update
const cfnAsg = asg.node.defaultChild as cdk.CfnResource;
const originalValue = <get the original valeu>;
cfnAsg.addPropertyOverride('DeletionProtection', autoscaling.DeletionProtection.NONE);
// generate the cfn template used for updates
const templateString = JSON.stringify(Template.fromStack(asgStack).toJSON(), null, 2);
// now set the property back
cfnAsg.addPropertyOverride('DeletionProtection', originalValue);
// now use cfn updatestack in your predestoydid you try this? i would expect it to work. and one more thing: why do you set |
…at/add-deletionProtection-to-asg
|
Hi @matboros, Thanks again for your guidance, I really appreciate it.
I had added |
matboros
left a comment
There was a problem hiding this comment.
A pity you removed the predestroy hook, i liked it since it communicated intent better, but this works as well. thanks a lot for the contribution!
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Merge Queue StatusRule:
This pull request spent 14 hours 58 minutes 22 seconds in the queue, including 9 hours 15 seconds running CI. Required conditions to merge
|
|
Comments on closed issues and PRs are hard for our team to see. |


Issue # (if applicable)
None
Reason for this change
ASG supports deletionProtection as documented in the CloudFormation reference.
Description of changes
deletionProtectionproperty toAutoScalingGroupPropsDescribe any new or updated permissions being added
None
Description of how you validated changes
Added unit/integ tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license