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

[Bug]: "AccessDenied" not handled correctly whilst aws_storagegateway_smb_file_share is in the state "Deleting..." #32768

Open
rba1-source opened this issue Jul 31, 2023 · 1 comment
Labels
bug Addresses a defect in current functionality. service/storagegateway Issues and PRs that pertain to the storagegateway service.

Comments

@rba1-source
Copy link

rba1-source commented Jul 31, 2023

Terraform Core Version

1.3.5

AWS Provider Version

4.66

Affected Resource(s)

  • aws_storagegateway_smb_file_share

Expected Behavior

aws provider should wait until the resource has finished being deleted before continuing

Actual Behavior

terraform polls AWS after it has sent the "delete SMB share" command to check if it has been deleted yet, but if the share is in the state "Deleting...", AWS returns "AccessDenied" which causes terraform to error out.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_storagegateway_smb_file_share" "smbshare" {

  file_share_name = "share05"
  authentication  = "ActiveDirectory"
  gateway_arn     = var.gateway_arn
  location_arn    = var.bucket_arn
  role_arn        = var.role_arn
  valid_user_list = var.valid_user_list
  smb_acl_enabled = true
  read_only       = true
}

Steps to Reproduce

  1. run a terraform apply to deploy an SMB share
  2. delete the SMB share from your terraform code and then rerun your terraform apply (to delete the share)

Alternatively, perform an action that results in SMB share deletion, such as:

  1. deploy a FileGateway & SMB share
  2. redeploy but with a newer FileGateway AMI, which causes all the SMB shares to be destroyed from the old FileGateway and created on the new FileGateway

Debug Output

2023-04-27T15:39:02.292+0100 [ERROR] vertex "module.smb_share_05.aws_storagegateway_smb_file_share.smbshare (destroy)" error: waiting for Storage Gateway SMB File Share (arn:aws:storagegateway:eu-west-1::share/share-3DED5CE7) to delete: AccessDeniedException: User: arn:aws:sts:::assumed-role/deployer is not authorized to perform: storagegateway:DescribeSMBFileShares on resource: arn:aws:storagegateway:eu-west-1::share/share-3DED5CE7 because no identity-based policy allows the storagegateway:DescribeSMBFileShares action
status code: 400, request id: 51e5c638-caab-4d74-8eb5-350fec38364b

Panic Output

No response

Important Factoids

I spoke to AWS Support about this and they said that "Access Denied" is what AWS correctly returns if it is partway through the process of deleting the SMB share (i.e. it's in the "Deleting..." state). "InvalidGatewayRequestException" can be returned if you request/poll after the SMB share is deleted, or whilst it is in the "Deleting..." state. Specifically they said:
"If the share status is in the “Deleting” state, or just recently deleted, while the describe call is being made, both of these errors may be thrown as the resource is no longer available to be called or used while being deleted. The accessdenied error is being thrown as the resource is still in the process of being deleted and cannot yet be accessed."

The flow should be: terraform requests the resource be deleted, AWS starts deleting it, terraform polls AWS every few seconds until it returns a "this resource doesn't exist" response, then terraform continues.

But the flow is: terraform requests the resource be deleted, AWS starts deleting it, terraform polls AWS and receives an "Access Denied" response because the resource is in the "Deleting..." state and thus cannot be accessed to retrieve the current state, so terraform errors out.

The issue is intermittent because sometimes the resource gets deleted before the first time that terraform polls for it - in these cases, terraform behaves as expected and the 'apply' continues successfully.

References

No response

Would you like to implement a fix?

No

@rba1-source rba1-source added the bug Addresses a defect in current functionality. label Jul 31, 2023
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added service/storagegateway Issues and PRs that pertain to the storagegateway service. needs-triage Waiting for first response or review from a maintainer. labels Jul 31, 2023
@rba1-source rba1-source changed the title [Bug]: InvalidGatewayRequestException not handled correctly whilst aws_storagegateway_smb_file_share is being deleted [Bug]: "AccessDenied" not handled correctly whilst aws_storagegateway_smb_file_share is in the state "Deleting..." Jul 31, 2023
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/storagegateway Issues and PRs that pertain to the storagegateway service.
Projects
None yet
Development

No branches or pull requests

2 participants