-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Feature Request] Make sam delete
clean up all SAM managed resources including aws-sam-cli-managed-default
stack
#7782
Comments
Looks like this is part of the "overall" sam setup, and not specific to an application. After a
|
I have a few follow-up questions:
|
I was not prompted for one, sam generated one for me:
I didn't specify a stack name, allowing sam to detect automatically. This command failed to delete anything, since it was never deployed:
I'm referring to There's no sam command I could find that runs a delete on that stack, so I tried via the CloudFormation console, and found out (the hard way) that CFN couldn't delete a non-empty bucket, and even when manually deleting the single object, I then found out that there's versions as well, which made it even harder to delete. What I'd expect is some sort of sam command that empties the bucket from all objects and versions, and runs a CFN delete on |
Question 1
I have attempt to reproduce the issue and see that I was prompted.
Question 2The same as above, the issue does not seem to happen with sam cli version 1.132.0 as shown below:
Please verify if the update version solve the issue. Question 3
The The behavior you're experiencing is actually due to an underlying CloudFormation limitation. CloudFormation intentionally prevents the deletion of non-empty S3 buckets (including buckets with versioned objects) as a safety mechanism to prevent accidental data loss. Since SAM CLI relies on CloudFormation for resource provisioning and management (including deletion), this CloudFormation limitation binds us. To fully clean up these resources, you would need to manually remove all objects and their versions from the bucket before the CloudFormation stack (and bucket) can be deleted. |
Hi @vicheey, thanks for following up. Question 1
I had supplied that in my original report - per your template, under
This is an unsatisfying response. I understand "upgrade to latest and try again" - but it's not like I was far behind, and nothing in the release notes or diff between versions points to this issue being resolved. Is there any specific commit you can point to that resolves this? It's okay if not, since it's not the issue I'm worried about. Question 2
Which you are showing as well. But note - this is not the problem, the stack was never deployed, so there's nothing to remove, so it's a nonsensical question from the tool. Question 3 Using
That makes sense, but nowhere does
That's a fine explanation of CloudFormation, but the entire point of using I remain of the opinion that if |
Thank you for clarifying the issue. Since this is currently an expected behavior of We have a roadmap here, but we also try to take in popular feature requests based on 👍🏽 from the community. We will be adding this to our intake for prioritization. Once again, thank you for your contribution. |
sam delete
sam delete
clean up all SAM managed resources including aws-sam-cli-managed-default
stack
Description:
After running
sam package
, a CloudFormation stackaws-sam-cli-managed-default
is created, with 2 resources -SamCliSourceBucket
&SamCliSourceBucketBucketPolicy
.Running
sam delete
errors out, and does not remove the bucket, policy, or CFN stack.Steps to reproduce:
sam init
a hello_world or other template, do NOT deploy yet.Observed result:
Expected result:
The bucket, artifacts, polciy, and cloudformation stack are removed completely.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
The text was updated successfully, but these errors were encountered: