Fail on delete of the stack
reisub83 opened this issue · 3 comments
Hi!
I created the stack on the eu-central-1 region
To completely delete the stack I executed the following command
for REGION in eu-central-1 us-east-1 ; do
sam delete --s3-bucket s3-bucketname --stack-name sam-stack-name --region ${REGION} --profile myprofile ;
done
the deletion on eu-central-1 gone successful, but failed on us-east-1 :
Are you sure you want to delete the stack sam-stack-name in the region eu-central-1 ? [y/N]: y
Do you want to delete the template file 49c34c698e66e09ee2bc.template in S3? [y/N]: y
- Deleting S3 object with key 75b1adeb7a9cb0964bf9
- Deleting S3 object with key 2e1f974ee72780ad9e0c
- Deleting S3 object with key d3de60b067da4e19718d
- Deleting S3 object with key 70d10d9c80ff26e37cf7
- Deleting S3 object with key 5c80760646d3a001f057
- Deleting S3 object with key e111a52f91d0ae46e144
- Deleting S3 object with key 32d991d29b3f86653d34
- Deleting S3 object with key 62c2026a5733b47d78d2
- Deleting S3 object with key fc6116227b5662ec55a2
- Deleting S3 object with key 4f87120c7718c9744291
- Deleting S3 object with key b929ab24fabf16384dd1
- Deleting S3 object with key 3426fde0f17395015991
- Deleting S3 object with key a152dd47fcdc95618996
- Deleting S3 object with key 2b48c4cec8ef1f80d9c2
- Deleting S3 object with key 154bfd03db7eb5c95e17
- Deleting S3 object with key 49c34c698e66e09ee2bc.template
- Deleting Cloudformation stack sam-stack-name
Deleted successfully
Are you sure you want to delete the stack sam-stack-name in the region us-east-1 ? [y/N]: y
Do you want to delete the template file 78ad5637694c27ece5b7.template in S3? [y/N]: y
- Could not find and delete the S3 object with the key 5c80760646d3a001f057
- Could not find and delete the S3 object with the key 70d10d9c80ff26e37cf7
- Could not find and delete the S3 object with the key 2e1f974ee72780ad9e0c
- Could not find and delete the S3 object with the key 75b1adeb7a9cb0964bf9
- Could not find and delete the S3 object with the key d3de60b067da4e19718d
- Could not find and delete the S3 object with the key 78ad5637694c27ece5b7.template
- Deleting Cloudformation stack sam-stack-name
Error: Stack sam-stack-name could not be deleted as it encountered DELETE_FAILED, msg: ex: Waiter StackDeleteComplete failed: Waiter encountered a terminal failure state:
For expression "Stacks[].StackStatus" we matched expected path: "DELETE_FAILED" at least once, status: The following resource(s) failed to delete: [AuthEdgeDeploymentBucket].
Now I have some objects (cloudformartion) that are on DELETE_FAILED state in both region, and I cant redploy the stack:
CREATE_FAILED Custom::UsEast1LambdaEdgeDeployment UsEast1Deployment Received response status [FAILED] from
custom resource. Message returned:
ValidationError:
Stack:arn:aws:cloudformation:us-
east-1:xxxxxxxxx:stack/sam-stack-name/e44xxxxx227cb is in DELETE_FAILED
state and can not be updated. (RequestId:
27de9847-7f1b-xxxxxxx-d126089)
to solve, we add this command to empty all the buckets before running sam delete
aws s3 ls | cut -d" " -f 3|grep "sam-stack-name.*" | xargs -I{} aws s3 rm s3://{} --recursive
And than we faced this error
Error: Stack sam-stack-name could not be deleted as it encountered DELETE_FAILED, msg: ex: Waiter StackDeleteComplete failed: Waiter encountered a terminal failure state: For expression "Stacks[].StackStatus" we matched expected path: "DELETE_FAILED" at least once, status: The following resource(s) failed to delete: [SignOutHandler, RefreshAuthHandler, TrailingSlashHandler, HttpHeadersHandler, CheckAuthHandler, ParseAuthHandler]
Which is the best way to destroy the stack?
So the original error reason for the failed delete of the us-east-1 stack was that the bucket was non-empty?
That's annoying and we should fix that!
Not sure why you shouldn't be able to remove the stacks after cleaning the buckets yourself. You should be able to try the delete again. Maybe use AWS CLI (not SAM): aws cloudformation delete-stack --stack-name sam-stack-name
The second error, after cleaning the bucket, was related to the Lambda@Edge function association in Cloudfront Behaviors.
We had to manually remove associations , wait some time (for cloudfront to propagate to edge nodes, I think), and than the sam delete in us-east-1 has worked
Ok. That is also an annoying one, and I know of no other work around than to wait as you do.
I did implement S3 empty bucket in #243 (and released v2.1.7). One less annoying thing to worry about ;)
Will close this issue as the other issue is beyond the control of this solution. It must be fixed/improved by the AWS service team.