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

New resource r/aws_wafv2_rule_group #12677

Merged
merged 24 commits into from
Jun 8, 2020

Conversation

pvanbuijtene
Copy link
Contributor

@pvanbuijtene pvanbuijtene commented Apr 4, 2020

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 #11175
Relates #11046

This PR can not be merged before #12119 #12284 are merged because of copied code for testing purpose.

Release note for CHANGELOG:

* **New Resource**: `aws_wafv2_rule_group` (#12677)

Output from acceptance testing:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAwsWafv2RuleGroup'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAwsWafv2RuleGroup -timeout 120m
...
--- PASS: TestAccAwsWafv2RuleGroup_Disappears (117.19s)
--- PASS: TestAccAwsWafv2RuleGroup_Minimal (168.75s)
--- PASS: TestAccAwsWafv2RuleGroup_RegexPatternSetReferenceStatement (185.19s)
--- PASS: TestAccAwsWafv2RuleGroup_IpSetReferenceStatement (192.05s)
--- PASS: TestAccAwsWafv2RuleGroup_ChangeCapacityForceNew (279.87s)
--- PASS: TestAccAwsWafv2RuleGroup_ChangeNameForceNew (280.85s)
--- PASS: TestAccAwsWafv2RuleGroup_ChangeMetricNameForceNew (283.66s)
--- PASS: TestAccAwsWafv2RuleGroup_GeoMatchStatement (306.63s)
--- PASS: TestAccAwsWafv2RuleGroup_SizeConstraintStatement (307.42s)
--- PASS: TestAccAwsWafv2RuleGroup_SqliMatchStatement (309.75s)
--- PASS: TestAccAwsWafv2RuleGroup_ByteMatchStatement (310.09s)
--- PASS: TestAccAwsWafv2RuleGroup_XssMatchStatement (311.26s)
--- PASS: TestAccAwsWafv2RuleGroup_Basic (313.17s)
--- PASS: TestAccAwsWafv2RuleGroup_Tags (334.43s)
--- PASS: TestAccAwsWafv2RuleGroup_RuleAction (352.86s)
--- PASS: TestAccAwsWafv2RuleGroup_LogicalRuleStatements (355.66s)
--- PASS: TestAccAwsWafv2RuleGroup_ByteMatchStatement_FieldToMatch (475.34s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       443.877s
...

There's a lot of code required for testing IpSetRefStatement and RegexPatternSetRefStatement, this was the only way I could make it work, maybe/hope there's an other way to simplify it.

The code for aws_wafv2_ip_set and aws_wafv2_regex_pattern_set is included for the tests, this should be removed after their PRs are merged.

The field statement is recursive this is implemented with a maximum of 3 levels, more levels had a serious performance impact resulting in long test runs. I don't know if this impact is only during testing or if it also impacts run time.

@pvanbuijtene pvanbuijtene requested a review from a team April 4, 2020 18:26
@ghost ghost added size/XXL Managed by automation to categorize the size of a PR. needs-triage Waiting for first response or review from a maintainer. provider Pertains to the provider itself, rather than any interaction with AWS. service/wafv2 Issues and PRs that pertain to the wafv2 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. documentation Introduces or discusses updates to documentation. labels Apr 4, 2020
@bflad bflad added new-resource Introduces a new resource. and removed needs-triage Waiting for first response or review from a maintainer. labels May 1, 2020
@pvanbuijtene pvanbuijtene force-pushed the wafv2-rule-group branch 4 times, most recently from 7840c68 to 2000577 Compare May 5, 2020 19:37
@anGie44
Copy link
Contributor

anGie44 commented May 12, 2020

hi @pvanbuijtene 👋 -- dropping a note here to rebase and isolate the resource changes when you get a chance :)

@pvanbuijtene
Copy link
Contributor Author

@anGie44 it's rebased.
With "isolate the resource changes" you mean to remove the duplicated code for testing purposes?

// The value is returned in lower case by the API.
// Trying to solve it with StateFunc and/or DiffSuppressFunc resulted in hash problem of the rule field or didn't work.
validateWafv2StringIsLowerCase(),
),
Copy link
Contributor

@anGie44 anGie44 May 18, 2020

Choose a reason for hiding this comment

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

if the validation is needed here (validateWafv2StringIsLowerCase) for case, we should use the validation package's StringMatch (see #11872 for related tech-debt efforts to stray from custom fns)
e.g.

validation.StringMatch(regexp.MustCompile(`^[a-z]+$`), "must contain only lowercase alpha characters"),

Copy link
Contributor

Choose a reason for hiding this comment

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

let's keep this validatonfunc but slightly adjust the message to include "lowercase"

Copy link
Contributor

Choose a reason for hiding this comment

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

@pvanbuijtene last note ^^ to adjust the error message that will appear in the output

aws/resource_aws_wafv2_rule_group.go Outdated Show resolved Hide resolved
// The value is returned in lower case by the API.
// Trying to solve it with StateFunc and/or DiffSuppressFunc resulted in hash problem of the rule field or didn't work.
validateWafv2StringIsLowerCase(),
),
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above

Copy link
Contributor

Choose a reason for hiding this comment

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

@pvanbuijtene last note ^^ to adjust the error message that will appear in the output

@anGie44
Copy link
Contributor

anGie44 commented May 18, 2020

@pvanbuijtene thanks again for this PR! please find some additional comments above :)

@anGie44 anGie44 added the waiting-response Maintainers are waiting on response from community or contributor. label May 19, 2020
@maryelizbeth maryelizbeth added this to the Roadmap milestone May 19, 2020
Copy link
Contributor

@anGie44 anGie44 left a comment

Choose a reason for hiding this comment

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

Just some minor comments re: validation messages, otherwise LGTM @pvanbuijtene!

Output of acceptance tests:

--- PASS: TestAccAwsWafv2RuleGroup_Disappears (155.13s)
--- PASS: TestAccAwsWafv2RuleGroup_Minimal (203.12s)
--- PASS: TestAccAwsWafv2RuleGroup_IpSetReferenceStatement (227.23s)
--- PASS: TestAccAwsWafv2RuleGroup_RegexPatternSetReferenceStatement (227.50s)
--- PASS: TestAccAwsWafv2RuleGroup_ChangeNameForceNew (358.05s)
--- PASS: TestAccAwsWafv2RuleGroup_ChangeCapacityForceNew (360.83s)
--- PASS: TestAccAwsWafv2RuleGroup_ChangeMetricNameForceNew (361.10s)
--- PASS: TestAccAwsWafv2RuleGroup_XssMatchStatement (393.38s)
--- PASS: TestAccAwsWafv2RuleGroup_ByteMatchStatement (396.52s)
--- PASS: TestAccAwsWafv2RuleGroup_SizeConstraintStatement (398.77s)
--- PASS: TestAccAwsWafv2RuleGroup_GeoMatchStatement (407.44s)
--- PASS: TestAccAwsWafv2RuleGroup_Basic (408.00s)
--- PASS: TestAccAwsWafv2RuleGroup_SqliMatchStatement (410.37s)
--- PASS: TestAccAwsWafv2RuleGroup_Tags (427.96s)
--- PASS: TestAccAwsWafv2RuleGroup_RuleAction (453.51s)
--- PASS: TestAccAwsWafv2RuleGroup_LogicalRuleStatements (454.33s)
--- PASS: TestAccAwsWafv2RuleGroup_ByteMatchStatement_FieldToMatch (580.12s)

@pvanbuijtene
Copy link
Contributor Author

Just some minor comments re: validation messages

@anGie44 missed those, thanks for the reminder

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label May 29, 2020
@pvanbuijtene pvanbuijtene requested a review from anGie44 May 29, 2020 22:22
@anGie44 anGie44 requested a review from bflad June 1, 2020 15:26
@anGie44
Copy link
Contributor

anGie44 commented Jun 1, 2020

hi @pvanbuijtene, i think the messaging is almost there 😅 just that we still need reference to the number and hyphen characters as you had it previously: must contain only lowercase alphanumeric characters, underscores, and hyphens

@anGie44 anGie44 added the waiting-response Maintainers are waiting on response from community or contributor. label Jun 2, 2020
@pvanbuijtene
Copy link
Contributor Author

pvanbuijtene commented Jun 2, 2020

@anGie44 went a bit too fast there, it's corrected.

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Jun 2, 2020
@anGie44
Copy link
Contributor

anGie44 commented Jun 2, 2020

no worries @pvanbuijtene, thank you for the update!

Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Excellent work, @pvanbuijtene and @anGie44 🚀 (We don't typically want dynamic schema generation as a pattern that may propagate to other resources, but in this case it is practically unavoidable without full on code generation. 😄 )

Output from acceptance testing:

--- PASS: TestAccAwsWafv2RuleGroup_Disappears (139.67s)
--- PASS: TestAccAwsWafv2RuleGroup_Minimal (197.18s)
--- PASS: TestAccAwsWafv2RuleGroup_RegexPatternSetReferenceStatement (227.26s)
--- PASS: TestAccAwsWafv2RuleGroup_IpSetReferenceStatement (232.16s)
--- PASS: TestAccAwsWafv2RuleGroup_ChangeNameForceNew (352.74s)
--- PASS: TestAccAwsWafv2RuleGroup_ChangeMetricNameForceNew (358.60s)
--- PASS: TestAccAwsWafv2RuleGroup_ChangeCapacityForceNew (361.48s)
--- PASS: TestAccAwsWafv2RuleGroup_XssMatchStatement (394.44s)
--- PASS: TestAccAwsWafv2RuleGroup_ByteMatchStatement (399.69s)
--- PASS: TestAccAwsWafv2RuleGroup_SizeConstraintStatement (400.45s)
--- PASS: TestAccAwsWafv2RuleGroup_SqliMatchStatement (401.30s)
--- PASS: TestAccAwsWafv2RuleGroup_GeoMatchStatement (402.20s)
--- PASS: TestAccAwsWafv2RuleGroup_Basic (408.86s)
--- PASS: TestAccAwsWafv2RuleGroup_Tags (426.98s)
--- PASS: TestAccAwsWafv2RuleGroup_RuleAction (449.06s)
--- PASS: TestAccAwsWafv2RuleGroup_LogicalRuleStatements (451.42s)
--- PASS: TestAccAwsWafv2RuleGroup_ByteMatchStatement_FieldToMatch (577.91s)

@anGie44 anGie44 merged commit 26275c3 into hashicorp:master Jun 8, 2020
@anGie44 anGie44 modified the milestones: Roadmap, v2.66.0 Jun 8, 2020
anGie44 added a commit that referenced this pull request Jun 8, 2020
@ghost
Copy link

ghost commented Jun 12, 2020

This has been released in version 2.66.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 for triage. Thanks!

@ghost
Copy link

ghost commented Jul 8, 2020

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!

@ghost ghost locked and limited conversation to collaborators Jul 8, 2020
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. new-resource Introduces a new resource. provider Pertains to the provider itself, rather than any interaction with AWS. service/wafv2 Issues and PRs that pertain to the wafv2 service. size/XXL 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
Development

Successfully merging this pull request may close these issues.

Feature Request: WAFv2 Rule Group Resource
4 participants