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

aws_lakeformation_permissions inconsistent result after apply #19643

Closed phzietsman closed 3 years ago

phzietsman commented 3 years ago

Community Note

Terraform CLI and Terraform AWS Provider Version

Terraform v0.15.5
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.43.0

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.

resource "aws_lakeformation_permissions" "data_producer_database" {

  provider = aws.lf_data_producer

  principal = var.org_arn

  permissions                   = ["DESCRIBE"]
  permissions_with_grant_option = ["DESCRIBE"]

  database {
    name       = aws_glue_catalog_database.data_producer.name
    catalog_id = data.aws_caller_identity.lf_data_producer.account_id
  }
}

variable "org_arn" {
  default = "arn:aws:organizations::xxx:organization/o-zzzzzz"
}

Expected Behavior

Permissions to be added to the Glue database that gives the entire AWS Organization DESCRIBE access and the changes to be reflected in the state file.

Actual Behavior

The changes are applied in the AWS, but the state does not reflect the changes. This only occurs when applying permissions to organizations and organizational units, when giving access to other accounts, this error does not occur.

Subsequent applies creates another resource in AWS and give the same error, resulting in multiple permission entries for the same Org/OU.

aws_lakeformation_permissions.data_producer_database: Creating...
β•·
β”‚ Error: Provider produced inconsistent result after apply
β”‚ 
β”‚ When applying changes to aws_lakeformation_permissions.data_producer_database, provider
β”‚ "provider[\"registry.terraform.io/hashicorp/aws\"].lf_data_producer" produced an
β”‚ unexpected new value: Root resource was present, but now absent.
β”‚ 
β”‚ This is a bug in the provider, which should be reported in the provider's own issue
β”‚ tracker.

Steps to Reproduce

  1. terraform apply
ramprasadtx commented 3 years ago

We are using * provider.aws: version = "~> 3.42". PFA attached build file with error

Step 1 (worked FINE) resource "aws_lakeformation_permissions" "test_athenalf_table" { principal = "arn:aws:iam::ACCCT:role/app-athena-lf-user" permissions = ["SELECT"]

table_with_columns { database_name = "lffix" name = "lffix" column_names=["amt","age"] } }

When we Changed to :

resource "aws_lakeformation_permissions" "test_athenalf_table" { principal = "arn:aws:iam::ACCCT:role/app-athena-lf-user" permissions = ["SELECT"]

table_with_columns { database_name = "lffix" name = "lffix" column_names=["amt"] } }

It FAILED with This is a bug in the provider, which should be reported in the provider's own issue tracker. 2021/06/04 19:34:01 [ERROR] : eval: *terraform.EvalSequence, err: Provider produced inconsistent result after apply: When applying changes to aws_lakeformation_permissions.test_athenalf_table, provider "registry.terraform.io/-/aws" produced an unexpected new value for was present, but now absent.

YakDriver commented 3 years ago

This bug would be reproduced by the new testAccAWSLakeFormationPermissions_tableWithColumns() acceptance test in #19817. That verifies that the bug is resolved with the PR.

github-actions[bot] commented 3 years ago

This functionality has been released in v3.46.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 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.