Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lakeformation: Add new aws_lakeformation_resource_lf_tags resource #25565

Merged
merged 15 commits into from
Jun 28, 2022

Conversation

YakDriver
Copy link
Member

@YakDriver YakDriver commented Jun 24, 2022

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #19640
Closes #20996
Relates #19523
Relates #19648

Output from acceptance testing:

% make testacc TESTS="TestAccLakeFormation_serial/ResourceLFTags" PKG=lakeformation
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/lakeformation/... -v -count 1 -parallel 20 -run='TestAccLakeFormation_serial/ResourceLFTags'  -timeout 180m
--- PASS: TestAccLakeFormation_serial (283.81s)
    --- PASS: TestAccLakeFormation_serial/ResourceLFTags (283.81s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/tableWithColumns (66.94s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/basic (33.07s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/database (59.78s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/databaseMultiple (61.75s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/table (62.27s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/lakeformation	285.088s

@github-actions github-actions bot added documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. service/lakeformation Issues and PRs that pertain to the lakeformation service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/XL Managed by automation to categorize the size of a PR. labels Jun 24, 2022
@github-actions github-actions bot added github_actions Pull requests that update Github_actions code linter Pertains to changes to or issues with the various linters. repository Repository modifications; GitHub Actions, developer docs, issue templates, codeowners, changelog. labels Jun 24, 2022
@YakDriver
Copy link
Member Author

YakDriver commented Jun 24, 2022

@sbrandtb @danielcmessias @stevenayers @maiarareinaldo @simonB2020 Do you have any feedback on this PR?

Copy link
Contributor

@danielcmessias danielcmessias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, few small comments/questions

}

resource "aws_lakeformation_resource_lf_tags" "example" {
catalog_id = data.aws_caller_identity.current.account_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor but this is inferred by default, in which case probably not needed in these examples as you'd likely only be setting for multi-catalog / cross-account access setups?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

lf_tag {
key = "left"
value = "aintree"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if you assign the same key twice but with diferent values, e.g.

lf_tag {
  key   = "left"
  value = "luffield"
}

lf_tag {
  key   = "left"
  value = "aintree"
}

Does the LF api catch this and error, or will it silently pick one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It catches the error:

Error: creating AWS Lake Formation Resource LF Tags ({
          LFTags: [{
              TagKey: "tf-acc-test-1974583174579168682-2",
              TagValues: ["vale"]
            },{
              TagKey: "tf-acc-test-1974583174579168682",
              TagValues: ["luffield"]
            },{
              TagKey: "tf-acc-test-1974583174579168682",
              TagValues: ["woodcote"]
            }],
          Resource: {
            TableWithColumns: {
              ColumnNames: ["event","timestamp"],
              DatabaseName: "tf-acc-test-1974583174579168682",
              Name: "tf-acc-test-1974583174579168682"
            }
          }
        }): InvalidInputException: Provided list of tags contains duplicate tag key

}

if failures.Len() > 0 {
return names.DiagError(names.LakeFormation, names.ErrActionCreating, resourceLFTags, "", failures.ErrorOrNil())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be looking to update the terraform state for all/any of the successful lf_tag applies before exiting with error if there are any failures?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could return a diag.Warning for each LFTag that fails and only an overall diag.Error if failures.Len() == len(input. LFTags)?

Copy link
Member Author

@YakDriver YakDriver Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trouble is that we don't update state in Create (except a tiny bit). I'm not sure how helpful it would be in that these are very fast operations and on the next successful Read, the state will be fixed. I think we need to stick with the framework and let Read handle state updates unless there's some really compelling reason. This is all ForceNew, so it's going to Delete and Create again in order to do any creating. That may cause problems but updating state in Create won't fix that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know where else we're doing something like this so it might be a first. Stack of failure warning, as requested. In my testing, I haven't seen exactly what a failure is. For example, if you send duplicates of a key, you get an error back on the whole AddLFTagsToResource operation so this logic is never reached. Hopefully it won't confuse people.

@ewbankkit
Copy link
Contributor

% make testacc TESTS="TestAccLakeFormation_serial/ResourceLFTags" PKG=lakeformation
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/lakeformation/... -v -count 1 -parallel 20 -run='TestAccLakeFormation_serial/ResourceLFTags'  -timeout 180m
=== RUN   TestAccLakeFormation_serial
=== RUN   TestAccLakeFormation_serial/ResourceLFTags
=== RUN   TestAccLakeFormation_serial/ResourceLFTags/basic
=== RUN   TestAccLakeFormation_serial/ResourceLFTags/database
=== RUN   TestAccLakeFormation_serial/ResourceLFTags/databaseMultiple
=== RUN   TestAccLakeFormation_serial/ResourceLFTags/table
=== RUN   TestAccLakeFormation_serial/ResourceLFTags/tableWithColumns
--- PASS: TestAccLakeFormation_serial (155.17s)
    --- PASS: TestAccLakeFormation_serial/ResourceLFTags (155.17s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/basic (20.17s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/database (30.77s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/databaseMultiple (33.93s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/table (34.12s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/tableWithColumns (36.18s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/lakeformation	159.543s

@YakDriver
Copy link
Member Author

Looks great, few small comments/questions

Thank you for taking a look!

@stevenayers
Copy link
Contributor

@YakDriver this looks fantastic, thanks for closing the loop here.

Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

% make testacc TESTS="TestAccLakeFormation_serial/ResourceLFTags" PKG=lakeformation
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/lakeformation/... -v -count 1 -parallel 20 -run='TestAccLakeFormation_serial/ResourceLFTags'  -timeout 180m
=== RUN   TestAccLakeFormation_serial
=== RUN   TestAccLakeFormation_serial/ResourceLFTags
=== RUN   TestAccLakeFormation_serial/ResourceLFTags/tableWithColumns
=== RUN   TestAccLakeFormation_serial/ResourceLFTags/basic
=== RUN   TestAccLakeFormation_serial/ResourceLFTags/database
=== RUN   TestAccLakeFormation_serial/ResourceLFTags/databaseMultiple
=== RUN   TestAccLakeFormation_serial/ResourceLFTags/table
--- PASS: TestAccLakeFormation_serial (161.23s)
    --- PASS: TestAccLakeFormation_serial/ResourceLFTags (161.23s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/tableWithColumns (37.66s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/basic (17.18s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/database (35.28s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/databaseMultiple (33.85s)
        --- PASS: TestAccLakeFormation_serial/ResourceLFTags/table (37.26s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/lakeformation	166.215s

@YakDriver YakDriver merged commit f39c0f7 into main Jun 28, 2022
@YakDriver YakDriver deleted the f-lakeformation_lf_tag_resource branch June 28, 2022 16:20
@github-actions github-actions bot added this to the v4.21.0 milestone Jun 28, 2022
github-actions bot pushed a commit that referenced this pull request Jun 28, 2022
@github-actions
Copy link

github-actions bot commented Jul 1, 2022

This functionality has been released in v4.21.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
Copy link

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. github_actions Pull requests that update Github_actions code linter Pertains to changes to or issues with the various linters. provider Pertains to the provider itself, rather than any interaction with AWS. repository Repository modifications; GitHub Actions, developer docs, issue templates, codeowners, changelog. service/lakeformation Issues and PRs that pertain to the lakeformation service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
4 participants