-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Conversation
@sbrandtb @danielcmessias @stevenayers @maiarareinaldo @simonB2020 Do you have any feedback on this PR? |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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" | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
% 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 |
Thank you for taking a look! |
@YakDriver this looks fantastic, thanks for closing the loop here. |
There was a problem hiding this 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
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! |
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. |
Community Note
Closes #19640
Closes #20996
Relates #19523
Relates #19648
Output from acceptance testing: