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

[Bug]: aws_lakeformation_resource_lf_tags should support multiple LF tag values per LF tag key #28091

Closed deanmatter closed 1 year ago

deanmatter commented 2 years ago

Terraform Core Version

1.2.1

AWS Provider Version

4.40.0

Affected Resource(s)

aws_lakeformation_resource_lf_tags

Expected Behavior

I need to tag a Glue Database with multiple LF tag values for a single LF tag key. In the AWS LakeFormation Boto3 documentation, it's possible to provide a list of TagValues for a corresponding TagKey, with the add_lf_tags_to_resource function.

As a result, I was hoping to provide the aws_lakeformation_resource_lf_tags resource with a list of LF tag values as an argument, like the following:

resource "aws_lakeformation_resource_lf_tags" "example" {
  database {
    name = aws_glue_catalog_database.example.name
  }

  lf_tag {
    key   = aws_lakeformation_lf_tag.example.key
    value = ["stowe", "abbey"]    # note the list of strings here
  }
}

Actual Behavior

The value parameter in the lf_tag block of the aws_lakeformation_resource_lf_tags only supports string data type, so I am unable to provide a list of LF tag values. As a result, I am only able to add a single LF tag value per LF tag key attached to a database.

Relevant Error/Panic Output Snippet

Error: Incorrect attribute value type
on main.tf line 13, in resource "aws_lakeformation_resource_lf_tags" "example":
    value = ["stowe", "abbey"]
Inappropriate value for attribute "value": string required.

Terraform Configuration Files

resource "aws_lakeformation_lf_tag" "example" {
  key    = "right"
  values = ["abbey", "village", "luffield", "woodcote", "copse", "chapel", "stowe", "club"]
}

resource "aws_lakeformation_resource_lf_tags" "example" {
  database {
    name = aws_glue_catalog_database.example.name
  }

  lf_tag {
    key   = aws_lakeformation_lf_tag.example.key
    value = ["stowe", "abbey"]    # note the list of strings here
  }
}

Steps to Reproduce

Attempt to run a terraform plan with the above resource configuration and the error will be evident.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lakeformation.html#LakeFormation.Client.add_lf_tags_to_resource

Would you like to implement a fix?

No response

github-actions[bot] commented 2 years ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

dacreify commented 1 year ago

I don't believe it's possible to apply more than one value for the same tag to a resource. e.g. If you attempt this in the console UI it won't let you. I believe the reason for seeing a list as the value of TagValues is due to the API reusing a type that appears in other contexts where multiple values is valid. e.g. When specifying what values a tag can take.

gdavison commented 1 year ago

Thanks for submitting this, @deanmatter. Unfortunately, the API doesn't actually support multiple values. It fails with

InvalidInputException: Tag value wild card was found or input tag value list has size not equal to 1

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.