hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.77k stars 9.12k forks source link

[Bug]: Lakeformation_permissions doesn't revoke permissions when resource deleted/not found #36639

Open raman-aro opened 6 months ago

raman-aro commented 6 months ago

Terraform Core Version

1.5.5

AWS Provider Version

5.38.0

Affected Resource(s)

aws_lakeformation_permissions

Expected Behavior

Management of a lakeformation_permission resource should delete/revoke permissions if they are no longer in state.

Actual Behavior

The permission remains.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~>5.0"
    }
  }

  required_version = ">= 1.2.0"
}

provider "aws" {
  region = "us-west-2"
}

resource "aws_lakeformation_permissions" "lf_grant_on_target" {
  principal   = "arn:aws:iam::xxxxxxxxx:role/xxxxxxxx"
  permissions = ["SELECT"]

  table {
    catalog_id = "remote_catalog"
    database_name = "remote_db"
    name = "remote_table"
  }
}

Steps to Reproduce

  1. Create a table with a resource link to a table from a resource share in an external account
  2. Create a lakeformation permission for the table
  3. run terraform apply and see that terraform indicates the permission was created
  4. Verify the permission was created in AWS console.
  5. Delete the resource share from the external account
  6. run terraform destroy and see that terraform indicates the permission was deleted.
  7. Look at the AWS console and see that the permission still exists

Debug Output

[WARN]  provider.terraform-provider-aws_v5.38.0_x5: [WARN] WaitForState timeout after 1m0s
[WARN]  provider.terraform-provider-aws_v5.38.0_x5: [WARN] WaitForState starting 30s refresh grace period
[WARN]  provider.terraform-provider-aws_v5.38.0_x5: [WARN] Resource Lake Formation permissions (xxxxxxxxx) not found, removing from state (0 permissions)

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No

github-actions[bot] commented 6 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue