-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
d/aws_wafregional_web_acl: Add WAFRegional Web ACL lookup datasource #9321
d/aws_wafregional_web_acl: Add WAFRegional Web ACL lookup datasource #9321
Conversation
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.
Hi @robh007 👋 Thank you so much for this contribution! Overall this is looking pretty good, just left a few items below to fix up so we can merge this. 👍 Please reach out if you have any questions or do not have time to implement these items.
) | ||
|
||
func TestAccDataSourceAwsWafRegionalWebAcl_Basic(t *testing.T) { | ||
name := "tf-acc-test" |
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.
Can you please randomize the naming to prevent issues where the test may have left existing resources? Please see also the Uses Randomized Infrastructure Naming
item of the Contributing Guide Thanks!
name := "tf-acc-test" | |
name := acctest.RandomWithPrefix("tf-acc-test") |
aws/data_source_aws_waf_web_acl.go
Outdated
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"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.
Can you please remove the id
attribute from the schema? It is implicit with all Terraform resources. Thanks!
aws/data_source_aws_waf_web_acl.go
Outdated
@@ -0,0 +1,64 @@ | |||
package aws |
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.
Can you please name this file aws/data_source_aws_wafregional_web_acl.go
to match the data source naming? Thanks!
@@ -0,0 +1,78 @@ | |||
package aws |
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.
Can you please name this file aws/data_source_aws_wafregional_web_acl_test.go
to match the data source naming? Thanks!
}) | ||
} | ||
|
||
func testAccDataSourceAwsWafRegionalWebAclConfig_Name(name string) string { |
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.
Since we do not need to verify the rules within the Web ACL and they are optional in the resource, can you please remove the extra infrastructure from the test configuration? Thanks!
func testAccDataSourceAwsWafRegionalWebAclConfig_Name(name string) string {
return fmt.Sprintf(`
resource "aws_wafregional_web_acl" "web_acl" {
name = %[1]q
metric_name = "tfWebACL"
default_action {
type = "ALLOW"
}
}
data "aws_wafregional_web_acl" "web_acl" {
name = "${aws_wafregional_web_acl.web_acl.name}"
}
`, name)
}
@@ -0,0 +1,30 @@ | |||
--- |
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.
page_title: "AWS: aws_wafregional_web_acl" | ||
sidebar_current: "docs-aws-datasource-wafregional-web-acl" | ||
description: |- | ||
Retrieves a WAF Regional Web ACL 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.
|
||
```hcl | ||
data "aws_wafregional_web_acl" "example" { | ||
name = "tfWAFRule" |
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.
Terraform formatting:
name = "tfWAFRule" | |
name = "tfWAFRule" |
Thanks for the review @bflad, I'll get these sorted. |
Changes as requested. @bflad I pushed 3 new data resources for WAF with this work. So I'll go back and check all of those inline with these comments. Retested. |
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.
Thanks for making these changes, @robh007! 🚀
FYI, I changed the wording in the initial comment from "fixes" to "related" - since #2654 spans multiple data sources, we don't want this one PR to close that whole issue (which the fixes keyword does).
Output from acceptance testing:
[TestAccDataSourceAwsWafRegionalWebAcl_Basic] [Test Output]
=== RUN TestAccDataSourceAwsWafRegionalWebAcl_Basic
=== PAUSE TestAccDataSourceAwsWafRegionalWebAcl_Basic
=== CONT TestAccDataSourceAwsWafRegionalWebAcl_Basic
--- PASS: TestAccDataSourceAwsWafRegionalWebAcl_Basic (10.47s)
PASS
👍
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
AWS WAFRegional Web ACL lookup datasource
Community Note
Related #2654
Release note for CHANGELOG:
Output from acceptance testing: