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.87k stars 9.21k forks source link

Cannot update Lakeformation permisison for lf-tags #26557

Closed ctrongminh closed 1 year ago

ctrongminh commented 2 years ago

Community Note

Terraform CLI and Terraform AWS Provider Version

terraform -v

Terraform v1.2.4 on darwin_amd64

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp

resource "aws_lakeformation_permissions" "lf_tag" {
  count       = length(var.lf_permissions_with_lf_tags)
  principal   = var.lf_permissions_with_lf_tags[count.index].role_arn
  permissions = var.lf_permissions_with_lf_tags[count.index].permissions

  lf_tag_policy {
    resource_type = var.lf_permissions_with_lf_tags[count.index].resource_type

    dynamic "expression" {
      for_each = var.lf_permissions_with_lf_tags[count.index].expression
      content {
        key    = expression.value["key"]
        values = expression.value["values"]
      }
    }
  }
}

input value for the list lf_permissions_with_lf_tags
lf_permissions_with_lf_tags = [
    {
      "role_arn": "arn:aws:iam::xxxxx:role/lf-tag",
      "permissions": ["SELECT"],
      "resource_type": "TABLE",
      "expression": [
        {
          "key": "test",
          "values": ["test"]
        }
      ]
    }
  ]

Debug Output

Panic Output

Expected Behavior

The existing lakeformation permission for the lf-tag should have been destroyed and recreated. In stead, I think it calls the update api, so it fails

Actual Behavior

The terraform apply failed with the below error

Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve.

Enter a value: yes

aws_lakeformation_permissions.lf_tag[2]: Modifying... [id=2540408176] ╷ │ Error: doesn't support update │ │ with aws_lakeformation_permissions.lf_tag[2], │ on lf_tags_permission.tf line 1, in resource "aws_lakeformation_permissions" "lf_tag": │ 1: resource "aws_lakeformation_permissions" "lf_tag" { │

Steps to Reproduce

  1. terraform apply
  2. Change the input lf-tag value to something else
  3. terraform apply
  4. The error will occur

Important Factoids

Currently, If I want to update the permission that has been deployed by terraform I need to do the workaround by calling destroy and then apply. But I think it should be done in the terraform code.

  1. Run terraform destroy for that resource
  2. Update the input / value
  3. Run terraform apply for the resource

References

earglass commented 1 year ago

Is there anything happening on this topic? I see ready PR, that sits here since September. What's the workaround for now? Seems lifecycle 'replace_triggered_by' is just ignored by this resource, so what's left, cloudformation stack? Or will we get some movement on this finally?

github-actions[bot] commented 1 year ago

This functionality has been released in v4.64.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.