Skip to content
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

Don't fail deleting an already deleted bucket #23

Closed
nhoughto opened this issue Jul 22, 2021 · 7 comments
Closed

Don't fail deleting an already deleted bucket #23

nhoughto opened this issue Jul 22, 2021 · 7 comments

Comments

@nhoughto
Copy link

Currently when terraform destroying a terraform managed bucket, the provider fails with an error if the bucket has already been deleted.

Error is : Error: No such bucket: 629955074482c...

Since we are trying to delete the bucket, and the bucket is already deleted a more user-friendly behaviour would be to just complete successfully, this is the default behaviour for many providers including the AWS S3 bucket resource. At the moment the workaround is to terraform state rm.. the resource manually to fix the problem, this is obviously not ideal.

The reason the bucket is deleted outside of terraform is related to: #22 so a solution to either would work =)

@nhoughto
Copy link
Author

Hmm just tested this with 0.7.0 (we had to wait for TF 1.0 upgrade), and i still see this failing?

│ Error: Traceback (most recent call last):
│   File "b2_terraform/provider_tool.py", line 497, in run_command
│   File "b2_terraform/provider_tool.py", line 120, in run
│   File "b2_terraform/provider_tool.py", line 242, in resource_read
│   File "b2_terraform/api_wrapper.py", line 37, in get_bucket_by_id
│ b2sdk.exception.NonExistentBucket: No such bucket: b2d935b784127f137acc0e13

@nhoughto
Copy link
Author

maybe the exception handling of BadRequest doesn't match what actually happens, says its throwing a NonExistentBucket exception?

@mszumocki-reef
Copy link
Collaborator

mszumocki-reef commented Oct 13, 2021

No, there's something else at play here - it's an error in resource_read, not resource_delete.
Could you check what terraform plan shows in this situation for you?

@nhoughto
Copy link
Author

nhoughto commented Oct 13, 2021 via email

@nhoughto
Copy link
Author

Looking at what the aws s3 resource terraform provider does, it logs a warning in Read if bucket doesn't exist and then removes the bucket from state, so no error is thrown, I believe this is what terraform expects in this situation, code:

https://github.com/hashicorp/terraform-provider-aws/blob/main/aws/resource_aws_s3_bucket.go#L835

@mszumocki-reef
Copy link
Collaborator

I'll be releasing that change in 0.7.1

@mszumocki-reef
Copy link
Collaborator

Released, @nhoughto please let me know if that works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants