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

Add tags to WAF WebACL, Rule & Rule Group Resources #10408

Merged
merged 27 commits into from
Oct 11, 2019

Conversation

DrFaust92
Copy link
Collaborator

@DrFaust92 DrFaust92 commented Oct 7, 2019

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" comments, they generate extra noise for pull request followers and do not help prioritize the request

Relates to #9289

Release note for CHANGELOG:

- resource/resource_aws_waf_rule: Add `tags` argument.
- resource/resource_aws_waf_web_acl: Add `tags` argument.
- resource/resource_aws_waf_rule_group: Add `tags` argument.

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSWaFWebAcl_'

=== RUN   TestAccAWSWafWebAcl_basic
=== PAUSE TestAccAWSWafWebAcl_basic
=== CONT  TestAccAWSWafWebAcl_basic
--- PASS: TestAccAWSWafWebAcl_basic (54.26s)
=== RUN   TestAccAWSWafWebAcl_changeNameForceNew
=== PAUSE TestAccAWSWafWebAcl_changeNameForceNew
=== CONT  TestAccAWSWafWebAcl_changeNameForceNew
--- PASS: TestAccAWSWafWebAcl_changeNameForceNew (76.04s)
=== RUN   TestAccAWSWafWebAcl_DefaultAction
=== PAUSE TestAccAWSWafWebAcl_DefaultAction
=== CONT  TestAccAWSWafWebAcl_DefaultAction
--- PASS: TestAccAWSWafWebAcl_DefaultAction (95.53s)
=== RUN   TestAccAWSWafWebAcl_Rules
=== PAUSE TestAccAWSWafWebAcl_Rules
=== CONT  TestAccAWSWafWebAcl_Rules
--- FAIL: TestAccAWSWafWebAcl_Rules (145.75s)
    testing.go:569: Step 2 error: errors during apply:
        
        Error: Error deleting WAF Rule: WAFReferencedItemException: This entity is still referenced by other entities.
        	status code: 400, request id: 04e760a2-ec28-11e9-92e8-8baa677d2d68
        
        
=== RUN   TestAccAWSWafWebAcl_LoggingConfiguration
=== PAUSE TestAccAWSWafWebAcl_LoggingConfiguration
=== CONT  TestAccAWSWafWebAcl_LoggingConfiguration
--- PASS: TestAccAWSWafWebAcl_LoggingConfiguration (197.73s)
=== RUN   TestAccAWSWafWebAcl_disappears
=== PAUSE TestAccAWSWafWebAcl_disappears
=== CONT  TestAccAWSWafWebAcl_disappears
--- PASS: TestAccAWSWafWebAcl_disappears (40.43s)
=== RUN   TestAccAWSWafWebAcl_Tags
=== PAUSE TestAccAWSWafWebAcl_Tags
=== CONT  TestAccAWSWafWebAcl_Tags
--- PASS: TestAccAWSWafWebAcl_Tags (105.80s)
...
$ make testacc TESTARGS='-run=TestAccAWSWaFRuleGroup_'

=== RUN   TestAccAWSWafRuleGroup_basic
=== PAUSE TestAccAWSWafRuleGroup_basic
=== CONT  TestAccAWSWafRuleGroup_basic
--- PASS: TestAccAWSWafRuleGroup_basic (67.32s)
=== RUN   TestAccAWSWafRuleGroup_changeNameForceNew
=== PAUSE TestAccAWSWafRuleGroup_changeNameForceNew
=== CONT  TestAccAWSWafRuleGroup_changeNameForceNew
--- PASS: TestAccAWSWafRuleGroup_changeNameForceNew (89.21s)
=== RUN   TestAccAWSWafRuleGroup_disappears
=== PAUSE TestAccAWSWafRuleGroup_disappears
=== CONT  TestAccAWSWafRuleGroup_disappears
--- PASS: TestAccAWSWafRuleGroup_disappears (55.54s)
=== RUN   TestAccAWSWafRuleGroup_changeActivatedRules
=== PAUSE TestAccAWSWafRuleGroup_changeActivatedRules
=== CONT  TestAccAWSWafRuleGroup_changeActivatedRules
--- PASS: TestAccAWSWafRuleGroup_changeActivatedRules (96.20s)
=== RUN   TestAccAWSWafRuleGroup_Tags
=== PAUSE TestAccAWSWafRuleGroup_Tags
=== CONT  TestAccAWSWafRuleGroup_Tags
--- PASS: TestAccAWSWafRuleGroup_Tags (96.91s)
=== RUN   TestAccAWSWafRuleGroup_noActivatedRules
=== PAUSE TestAccAWSWafRuleGroup_noActivatedRules
=== CONT  TestAccAWSWafRuleGroup_noActivatedRules
--- PASS: TestAccAWSWafRuleGroup_noActivatedRules (38.98s)
$ make testacc TESTARGS='-run=TestAccAWSWaFRule_'

=== RUN   TestAccAWSWafRule_basic
=== PAUSE TestAccAWSWafRule_basic
=== CONT  TestAccAWSWafRule_basic
=== RUN   TestAccAWSWafRule_changeNameForceNew
=== PAUSE TestAccAWSWafRule_changeNameForceNew
=== RUN   TestAccAWSWafRule_disappears
=== PAUSE TestAccAWSWafRule_disappears
=== CONT  TestAccAWSWafRule_disappears
=== RUN   TestAccAWSWafRule_changePredicates
=== PAUSE TestAccAWSWafRule_changePredicates
=== RUN   TestAccAWSWafRule_geoMatchSetPredicate
=== PAUSE TestAccAWSWafRule_geoMatchSetPredicate
=== CONT  TestAccAWSWafRule_geoMatchSetPredicate
=== RUN   TestAccAWSWafRule_noPredicates
=== PAUSE TestAccAWSWafRule_noPredicates
=== CONT  TestAccAWSWafRule_noPredicates
--- PASS: TestAccAWSWafRule_noPredicates (37.86s)
=== RUN   TestAccAWSWafRule_Tags
=== PAUSE TestAccAWSWafRule_Tags
=== CONT  TestAccAWSWafRule_Tags
--- PASS: TestAccAWSWafRule_basic (65.84s)
=== CONT  TestAccAWSWafRule_changePredicates
=== CONT  TestAccAWSWafRule_changeNameForceNew
--- PASS: TestAccAWSWafRule_geoMatchSetPredicate (69.30s)
--- PASS: TestAccAWSWafRule_disappears (53.59s)
--- PASS: TestAccAWSWafRule_Tags (108.77s)
--- PASS: TestAccAWSWafRule_changePredicates (80.81s)
--- PASS: TestAccAWSWafRule_changeNameForceNew (89.17s)

@DrFaust92 DrFaust92 requested a review from a team October 7, 2019 14:43
@ghost ghost added size/M Managed by automation to categorize the size of a PR. service/waf Issues and PRs that pertain to the waf service. labels Oct 7, 2019
@ghost ghost added size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. and removed size/M Managed by automation to categorize the size of a PR. labels Oct 7, 2019
@DrFaust92 DrFaust92 closed this Oct 7, 2019
@DrFaust92 DrFaust92 reopened this Oct 7, 2019
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. and removed size/L Managed by automation to categorize the size of a PR. labels Oct 8, 2019
@ghost ghost added the documentation Introduces or discusses updates to documentation. label Oct 9, 2019
aws_waf_rate_based_rule
aws_waf_rule
aws_waf_rule_group

and add create logic for these resources
aws_waf_rate_based_rule
aws_waf_rule
aws_waf_rule_group
                  aws_wafregional_rate_based_rule
                  aws_wafregional_rule
                  aws_wafregional_rule_group
                  aws_wafregional_web_acl
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.

Thanks again for submitting this, @DrFaust92 -- please reach out if you have any questions or do not have time to implement the feedback items. 😄

aws/tagsWAF.go Outdated Show resolved Hide resolved
aws/resource_aws_waf_web_acl.go Outdated Show resolved Hide resolved
aws/resource_aws_waf_web_acl.go Outdated Show resolved Hide resolved
aws/resource_aws_waf_web_acl.go Outdated Show resolved Hide resolved
aws/resource_aws_waf_web_acl_test.go Outdated Show resolved Hide resolved
@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. waiting-response Maintainers are waiting on response from community or contributor. labels Oct 10, 2019
@DrFaust92
Copy link
Collaborator Author

hey @bflad,
im new to golang and after the proposed change i get this message:
image

any idea what needs to change in the project settings? (i guess that is the issue and not the package itself)

@bflad
Copy link
Contributor

bflad commented Oct 10, 2019

@DrFaust92 hmm, since the internal package is within this Go module, it shouldn't be complaining. That seems like an issue with your editor. Here's some Go documentation on internal packages for reference.

Also please note that if these tag additions are done in separate PRs per-resource, we can merge them immediately once the resource code, acceptance testing, and documentation is ready for that one resource (rather than waiting for everything to be done). 😄

* aws_waf_rate_based_rule
* aws_waf_rule_group
* aws_waf_rule

refactored tests a bit to not repeat resource name
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. and removed size/L Managed by automation to categorize the size of a PR. labels Oct 10, 2019
@DrFaust92
Copy link
Collaborator Author

@bflad,
TestAccAWSWafWebAcl_Rules test seems to fail with the following error:

 Error: Error deleting WAF Rule: WAFReferencedItemException: This entity is still referenced by other entities.
        	status code: 400, request id: 04e760a2-ec28-11e9-92e8-8baa677d2d68
        

this is unrelated to the change im adding as it fails on master as well.

…ed_rule aws_wafregional_rule aws_wafregional_rule_group aws_wafregional_web_acl"

This reverts commit 34a3e53
@bflad
Copy link
Contributor

bflad commented Oct 11, 2019

@DrFaust92 thanks for bringing that up. Yeah, that one is indeed flakey/failing on master. You can ignore that in your testing. 👍

@DrFaust92 DrFaust92 changed the title [WIP] Add tags to waf resources Add tags to waf resources Oct 11, 2019
@DrFaust92
Copy link
Collaborator Author

Also please note that if these tag additions are done in separate PRs per-resource, we can merge them immediately once the resource code, acceptance testing, and documentation is ready for that one resource (rather than waiting for everything to be done). 😄

@bflad, i realised my mistake too late. descoping this to only a few resources and i'll open other PRs for other resources (or related tasks)

i think this is ready now. thanks for the support on this!

@DrFaust92 DrFaust92 changed the title Add tags to waf resources Add tags to WAF WebACL, Rule & Rule Group Resources Oct 11, 2019
@bflad bflad added this to the v2.33.0 milestone Oct 11, 2019
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.

Looks great, @DrFaust92, thanks so much for your work here! 🚀

--- PASS: TestAccAWSWafRuleGroup_noActivatedRules (15.91s)
--- PASS: TestAccAWSWafRuleGroup_Tags (39.80s)
--- PASS: TestAccAWSWafRule_Tags (70.48s)
--- PASS: TestAccAWSWafRule_changeNameForceNew (74.99s)
--- PASS: TestAccAWSWafRule_noPredicates (76.48s)
--- PASS: TestAccAWSWafWebAcl_DefaultAction (91.12s)
--- PASS: TestAccAWSWafWebAcl_Tags (93.10s)
--- PASS: TestAccAWSWafRuleGroup_basic (108.74s)
--- PASS: TestAccAWSWafWebAcl_disappears (109.73s)
--- PASS: TestAccAWSWafWebAcl_LoggingConfiguration (127.80s)
--- PASS: TestAccAWSWafWebAcl_basic (129.29s)
--- PASS: TestAccAWSWafRule_basic (141.68s)
--- PASS: TestAccAWSWafRule_geoMatchSetPredicate (142.90s)
--- PASS: TestAccAWSWafRuleGroup_changeActivatedRules (151.86s)
--- PASS: TestAccAWSWafRule_changePredicates (161.65s)
--- PASS: TestAccAWSWafWebAcl_changeNameForceNew (174.97s)
--- PASS: TestAccAWSWafRuleGroup_changeNameForceNew (181.00s)
--- PASS: TestAccAWSWafRule_disappears (192.69s)
--- PASS: TestAccAWSWafRuleGroup_disappears (205.69s)

@@ -109,6 +117,23 @@ func resourceAwsWafRuleRead(d *schema.ResourceData, meta interface{}) error {
predicates = append(predicates, predicate)
}

arn := arn.ARN{
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: For the future, it might be nice to expose the ARN as an attribute as well if folks need it for other reasons (and we can also use d.Get("arn").(string) in the Update function as well) 👍

In the resource code:

// Resource schema
"arn": {
	Type:     schema.TypeString,
	Computed: true,
}

// Read function (or Create function if needed in there first)
arn := arn.ARN{/* ... */}.String()
d.Set("arn", arn)

// Update function can access via
d.Get("arn").(string)

Acceptance testing:

// In the _basic test, one of the following
// Depending on global/regional ARN and known resource value (Check) or regex (Match)
testAccCheckResourceAttrGlobalARN(resourceName, "arn", "iam", fmt.Sprintf("policy/%s", rName)),

testAccMatchResourceAttrGlobalARN(resourceName, "arn", "organizations", regexp.MustCompile(`organization/o-.+`)),

testAccCheckResourceAttrRegionalARN(resourceName, "arn", "athena", fmt.Sprintf("workgroup/%s", rName)),

testAccMatchResourceAttrRegionalARN(resourceName, "arn", "acm", regexp.MustCompile(`certificate/.+`)),

Resource documentation (attributes section):

* `arn` - Amazon Resource Name (ARN)

@bflad bflad merged commit d562f95 into hashicorp:master Oct 11, 2019
bflad added a commit that referenced this pull request Oct 11, 2019
@DrFaust92 DrFaust92 deleted the waf-tags branch October 20, 2019 20:57
@ewbankkit ewbankkit mentioned this pull request Nov 8, 2019
@ghost
Copy link

ghost commented Mar 29, 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 Mar 29, 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. enhancement Requests to existing resources that expand the functionality or scope. service/waf Issues and PRs that pertain to the waf 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
Development

Successfully merging this pull request may close these issues.

2 participants