awslabs / route53-dynamic-dns-with-lambda

A Dynamic DNS system built with API Gateway, Lambda & Route 53.
Apache License 2.0
491 stars 166 forks source link

Can't delete cloudformation stack created by this cloud9 project #55

Closed angelotrivelli closed 8 months ago

angelotrivelli commented 8 months ago

I was testing out the dynamic dns functionality provided by this project and it worked smoothly, kudos to you guys!

But now I am done testing it out and I would like to delete it-- and this is where I think I did something wrong.

I had noticed this project created a DynamoDB and a Lambda function. I deleted those first and then the cloud-9 project and its EC2 instance with the assumption that that would be "enough".

But then I noticed it ALSO created a cloudformation stack. To be honest, I hadn't read carefully and just assumed the project used AWS cli to set everything up conveniently from a cloud-9 project. Sorry to say, I don't really know anything about cloudformation (other than it's a very complex tool to setup AWS infrastructure).

When I try to delete the cloudformation stack, it gives a "DELETE_FAILED" error with some message about a role: Role arn:aws:iam::999999999999:role/cdk-hnb9999ds-cfn-exec-role-999999999-us-east-2 is invalid or cannot be assumed

Here's a screenshot of the application manager: 2024-02-27 08_39_12-Resource Details - AWS Systems Manager - Application Manager

Looking in the application manager, I see that it STILL lists a DynamoDB table and Lambda function. When I click on their links, these resources are no longer present (I had deleted them after all). There's also an IAM role in there, I can't tell if it refers to the same role in the error message (it's not listed as an arn URL).

I tried finding the IAM role listed in the error message (could not), tried switching to admin and root role to delete (didn't work). I also found this information, but I wasn't able to identify the right role from looking at the arn url in the message. I ended up just selecting "AWSCloudFormationFullAccess" role for my user (also didn't work).

I can't find a way to delete this stack and now I am stuck. It's not a big deal but I don't like having stuff like this hanging around.

So 3 questions: 1) What did I do wrong? 2) What is the correct way to delete all traces of the stuff created by this cloud-9 project? 3) How do I now delete this stack?

Thank you for your patience !!

masberta commented 8 months ago

Ciao Angelo, the resources are deployed via CDK, which generate a CloudFormation stack. The proper way to delete the resources would have been to delete the stack itself without manually remove any of the stack resources.

Cloud9 is just a service providing an IDE in the Cloud and that is not part of the stack and requires manual deletion.

The stack is now failing do delete because it cannot find the role, I assumed you deleted that manually too? Verify the role arn:aws:iam::999999999999:role/cdk-hnb9999ds-cfn-exec-role-999999999-us-east-2 is indeed missing and recreate it with the exact same name and try again to delete the stack.

When deploying with CDK or directly with CloudFormation resources it should never be manually deleted. I will update the README.md to provide more clear instructions on how to delete the stack.

Be reassured that the stack itself is not incurring in any cost.

angelotrivelli commented 8 months ago

That worked, thank you!