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

lakeformation_permissions: Throws "no permissions found" error if no permissions_with_grant_options property is used #19064

Closed MitchellGerdisch closed 3 years ago

MitchellGerdisch commented 3 years ago

Community Note

Terraform CLI and Terraform AWS Provider Version

Affected Resource(s)

Terraform Configuration Files

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

terraform {
  required_version = ">= 0.14.0"
}

provider "aws" {
  region = "us-east-1"
}

resource "aws_lakeformation_permissions" "add-pii-clientstest-tf" {
  principal   = "arn:aws:iam::xxxxxxxxx:role/xxxxxxxx"
  permissions = ["SELECT"]

  table_with_columns {
    database_name = "mydb"
    name = "mytable"
    column_names =  ["mycolumn"]
  }
}

Debug Output

Panic Output

Expected Behavior

As per the documentation, the permissions_with_grant_option is optional (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lakeformation_permissions#permissions_with_grant_option) And creating resource without that option should work as expected.

Actual Behavior

Without that option a few things happen:

  1. This error is given: │ Error: error reading Lake Formation permissions: no permissions found
  2. But the resource is created as seen in the AWS console, for example.
  3. Any attempt to modify, refresh or destroy the resource continues to throw the error.
  4. Thus, manual deletion of the permission in AWS is required and
  5. The state file needs to be modified to get things back to a sane state.

Steps to Reproduce

  1. Create an Athena db/table
  2. Create a role.
  3. Create a lakeformation permission resource for the role on the Athena table as per the code above.
  4. terraform apply and see the error.
  5. Note that even though an error is thrown, the permission was created in AWS console.
  6. Try any other terraform command (e.g. apply, destroy, refresh) and get the error (with or without untainting).

Important Factoids

References

YakDriver commented 3 years ago
Additional Principals Perm Delete/Revoke
Related #16848 (Issue)
Related #16916
Related #18034 (Issue)
Related #18374
Related #17633 (Issue)
Related #18446 (Issue)
Related #18505
Related #19063 (Issue)
Related #19064 (Issue)
ghost commented 3 years ago

This has been released in version 3.39.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 for triage. Thanks!

github-actions[bot] commented 3 years 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.