A developer received the following error message during an AWS CloudFormation deployment: DELETE_FAILED (The following resource(s) failed to delete: [ASGInstanceRolel2345678].) Which action should the developer take to resolve this error?
A.
Contact AWS Support to report an issue with the Auto Scaling Groups (ASG) service.
B.
Add a DependsOn attribute to the ASGInstanceRole12345678 resource in the CloudFormation template. Then delete the stack.
C.
Modify the CloudFormation template to retain the ASGInstanceRolel2345678 resource. Then manually delete the resource after deployment.
D.
Add a force parameter when calling CloudFormation with the role-arn of ASGInstanceRolel2345678.
It is not mentioned anywhere that deletion failed due to dependency on something. For example CloudFormation cannot delete S3 buckets or ECR repositories if they are not empty. In this case only manual deletion helps. So "B" -> incorrect, C -> correct
B:
Declare dependencies for resources that must be created or deleted in a specific order (see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-dependson.html)
For the DependsOn attribute to be of any help here, it would need to be attached to another resource (a resource that depends on the ASG, and that needs to be deleted before the ASG). Here the option is to add the DependsOn attribute on the ASG itself, so it wouldn't help. B is not correct
C) If the role ASGInstanceRole12345678 cannot be deleted because other resources are still referencing it, the Retain policy allows you to bypass the dependency issue for now by preserving the role. Once the stack deletion completes, you can manually identify and resolve those dependencies before deleting the role.
https://repost.aws/knowledge-center/cloudformation-stack-delete-failed
For sure C is the correct answer because if CloudFormation failed because of a particular resource, we can 'retain' the specific resource and try another time the deletion of the template. Then, remove manually the specified resource.
Option C is wrong, it suggests modifying the CloudFormation template to retain the failing resource and then manually deleting it after deployment. This approach may work, but it is not the best practice for handling failed CloudFormation stack deletions. Manually deleting the resource after deployment can be time-consuming and prone to human error, and it may not address the root cause of the issue.
By adding a DependsOn attribute, option B, to the resource that depends on the ASGInstanceRolel2345678 resource, the CloudFormation stack deletion process will ensure that the ASGInstanceRolel2345678 resource is deleted first. Once this resource is deleted, the other resource can then be deleted successfully.
Your logic sounds good but I think there's one problem!
Option B suggests and even states that we are deleting the entire stack created from the AWS CloudFormation template!
But the question talks about this error occurring during the DEPLOYMENT of the specific CloudFormation template!
I don't think we delete the entire stack during deployment! No?
The question is what should the developer do to resolve the error. The question may be not correctly formed here, but I think B is more suitable to resolve the error.
C: due to parallel processing you might need to retain some stack resources and delete them manually later :https://aws.amazon.com/premiumsupport/knowledge-center/cloudformation-stack-delete-failed/
Do you mean C? The link is great, but it points to C:
"Important: To avoid unnecessary charges, you must manually delete the resources that are retained when the stack is deleted."
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
XAvenger
Highly Voted 2 years, 7 months agorobbyboss
Highly Voted 2 years, 7 months agoArnaud92
2 years, 6 months agosumanshu
Most Recent 4 months, 1 week ago5f7ff1a
1 year, 5 months agorcaliandro
1 year, 10 months agoSyre
2 years agonpn225
1 year, 6 months agosharmavipul92
2 years, 2 months agoKT_Yu
2 years, 3 months agorlnd2000
2 years, 1 month agohaazybanj
2 years, 6 months agoRUKSHANA
2 years, 7 months agodavid00
2 years, 7 months agoprincajen
2 years, 7 months agonothankyouspankyou
2 years, 5 months agoJabol
2 years, 7 months agoahmed308
2 years, 7 months ago