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.74k stars 9.1k forks source link

[Bug]: aws_lakeformation_permissions does not always revoke permission #39082

Open ronald8192 opened 2 weeks ago

ronald8192 commented 2 weeks ago

Terraform Core Version

1.9.5

AWS Provider Version

5.64.0

Affected Resource(s)

aws_lakeformation_permissions

Expected Behavior

Remove aws_lakeformation_permissions from Terraform code or run terraform destroy will revoke corresponding Lake Formation permission

Actual Behavior

Destroy aws_lakeformation_permissions.column resource not revoke the permission on Lake Formation, even it is showing resource will be destroy in the plan.

The bug only happens if:

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_lakeformation_permissions" "table" {
  principal                     = aws_iam_role.test.arn
  permissions                   = ["DESCRIBE"]
  permissions_with_grant_option = []

  table {
    catalog_id    = "111111111111"
    database_name = "my-catalog-db"
    wildcard      = true
  }
}

resource "aws_lakeformation_permissions" “column” {
  principal                     = aws_iam_role.test.arn
  permissions                   = ["SELECT"]
  permissions_with_grant_option = []

  table_with_columns {
    catalog_id    = "111111111111"
    database_name = "my-catalog-db"
    name          = "my-table"
    wildcard      = true
  }
}

resource "aws_iam_role" "test" {
  name = "my-test-role"

  assume_role_policy = jsonencode({
    "Version": "2012-10-17",
    "Statement": [
      {
        "Action": "sts:AssumeRole",
        "Principal": {
          "Service": "glue.amazonaws.com"
        },
        "Effect": "Allow",
        "Sid": ""
      }
    ]
  })
}

Steps to Reproduce

  1. Run terraform apply to create the permission and other dependent resources
  2. Comment out aws_lakeformation_permissions.column resource block
  3. Run terraform apply again
  4. Check Lake Formation permissions on console, the permission still exist

Debug Output

Apply log

Destroy log

# aws_lakeformation_permissions.column will be destroyed
# (because aws_lakeformation_permissions.column is not in configuration)
- resource "aws_lakeformation_permissions" "column" {
    - catalog_resource              = false -> null
    - id                            = "1234567890" -> null
    - permissions                   = [
        - "DESCRIBE",
        - "SELECT",
      ] -> null
    - permissions_with_grant_option = [] -> null
    - principal                     = "arn:aws:iam::222222222222:role/my-test-role" -> null

    - table_with_columns {
        - catalog_id    = "111111111111" -> null
        - database_name = "my-catalog-db" -> null
        - name          = "my-table" -> null
        - wildcard      = true -> null
      }
  }

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 2 weeks ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 2 weeks ago

Similar #36639 Similar #39009 Similar #28366