From 1ee9c5303efa5d6cc16259cc6ed25fb8ec6e185a Mon Sep 17 00:00:00 2001 From: Goh Hong Yi Date: Mon, 26 Feb 2024 13:23:54 +0800 Subject: [PATCH 1/3] add application integration url as exported attribute --- internal/service/wafv2/web_acl.go | 6 ++++++ internal/service/wafv2/web_acl_test.go | 5 +++++ website/docs/r/wafv2_web_acl.html.markdown | 1 + 3 files changed, 12 insertions(+) diff --git a/internal/service/wafv2/web_acl.go b/internal/service/wafv2/web_acl.go index 0b2155da157..4baa2533bad 100644 --- a/internal/service/wafv2/web_acl.go +++ b/internal/service/wafv2/web_acl.go @@ -63,6 +63,11 @@ func ResourceWebACL() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "application_integration_url": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, "association_config": associationConfigSchema(), "capacity": { Type: schema.TypeInt, @@ -253,6 +258,7 @@ func resourceWebACLRead(ctx context.Context, d *schema.ResourceData, meta interf d.Set("description", webACL.Description) d.Set("lock_token", output.LockToken) d.Set("name", webACL.Name) + d.Set("application_integration_url", output.ApplicationIntegrationURL) rules := filterWebACLRules(webACL.Rules, expandWebACLRules(d.Get("rule").(*schema.Set).List())) if err := d.Set("rule", flattenWebACLRules(rules)); err != nil { return diag.Errorf("setting rule: %s", err) diff --git a/internal/service/wafv2/web_acl_test.go b/internal/service/wafv2/web_acl_test.go index af403a0fa6a..e9a786b0820 100644 --- a/internal/service/wafv2/web_acl_test.go +++ b/internal/service/wafv2/web_acl_test.go @@ -51,6 +51,7 @@ func TestAccWAFV2WebACL_basic(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckWebACLExists(ctx, resourceName, &v), acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "wafv2", regexache.MustCompile(`regional/webacl/.+$`)), + resource.TestCheckResourceAttr(resourceName, "application_integration_url", ""), resource.TestCheckResourceAttr(resourceName, "association_config.#", "0"), resource.TestCheckResourceAttr(resourceName, "captcha_config.#", "0"), resource.TestCheckResourceAttr(resourceName, "challenge_config.#", "0"), @@ -523,6 +524,7 @@ func TestAccWAFV2WebACL_ManagedRuleGroup_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckWebACLExists(ctx, resourceName, &v), acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "wafv2", regexache.MustCompile(`regional/webacl/.+$`)), + resource.TestCheckResourceAttr(resourceName, "application_integration_url", ""), resource.TestCheckResourceAttr(resourceName, "name", webACLName), resource.TestCheckResourceAttr(resourceName, "rule.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ @@ -731,6 +733,7 @@ func TestAccWAFV2WebACL_ManagedRuleGroup_ManagedRuleGroupConfig_ACFPRuleSet(t *t Check: resource.ComposeTestCheckFunc( testAccCheckWebACLExists(ctx, resourceName, &v), acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "wafv2", regexache.MustCompile(`regional/webacl/.+$`)), + resource.TestMatchResourceAttr(resourceName, "application_integration_url", regexache.MustCompile(`https:\/\/.*\.sdk\.awswaf\.com.*`)), resource.TestCheckResourceAttr(resourceName, "name", webACLName), resource.TestCheckResourceAttr(resourceName, "rule.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ @@ -823,6 +826,7 @@ func TestAccWAFV2WebACL_ManagedRuleGroup_ManagedRuleGroupConfig_ATPRuleSet(t *te Check: resource.ComposeTestCheckFunc( testAccCheckWebACLExists(ctx, resourceName, &v), acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "wafv2", regexache.MustCompile(`regional/webacl/.+$`)), + resource.TestMatchResourceAttr(resourceName, "application_integration_url", regexache.MustCompile(`https:\/\/.*\.sdk\.awswaf\.com.*`)), resource.TestCheckResourceAttr(resourceName, "name", webACLName), resource.TestCheckResourceAttr(resourceName, "rule.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ @@ -909,6 +913,7 @@ func TestAccWAFV2WebACL_ManagedRuleGroup_ManagedRuleGroupConfig_BotControl(t *te Check: resource.ComposeTestCheckFunc( testAccCheckWebACLExists(ctx, resourceName, &v), acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "wafv2", regexache.MustCompile(`regional/webacl/.+$`)), + resource.TestMatchResourceAttr(resourceName, "application_integration_url", regexache.MustCompile(`https:\/\/.*\.sdk\.awswaf\.com.*`)), resource.TestCheckResourceAttr(resourceName, "name", webACLName), resource.TestCheckResourceAttr(resourceName, "rule.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ diff --git a/website/docs/r/wafv2_web_acl.html.markdown b/website/docs/r/wafv2_web_acl.html.markdown index ea811ee5a3b..daeea1e09b5 100644 --- a/website/docs/r/wafv2_web_acl.html.markdown +++ b/website/docs/r/wafv2_web_acl.html.markdown @@ -1053,6 +1053,7 @@ The `uri_path` block supports the following arguments: This resource exports the following attributes in addition to the arguments above: * `arn` - The ARN of the WAF WebACL. +* `application_integration_url` - The URL to use in SDK integrations with managed rule groups * `capacity` - Web ACL capacity units (WCUs) currently being used by this web ACL. * `id` - The ID of the WAF WebACL. * `tags_all` - Map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block). From a8a5eb5fd0e56cc16dd899acf8b314fb7eb7fb03 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 26 Feb 2024 10:44:07 -0500 Subject: [PATCH 2/3] Add CHANGELOG entry. --- .changelog/35974.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/35974.txt diff --git a/.changelog/35974.txt b/.changelog/35974.txt new file mode 100644 index 00000000000..90514f2abc4 --- /dev/null +++ b/.changelog/35974.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_wafv2_web_acl: Add `application_integration_url` attribute +``` \ No newline at end of file From c193db5b906d71ac42a41f2b771b009b5db5ff17 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 26 Feb 2024 10:45:43 -0500 Subject: [PATCH 3/3] Cosmetics. --- internal/service/wafv2/web_acl.go | 6 ++---- website/docs/r/wafv2_web_acl.html.markdown | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/internal/service/wafv2/web_acl.go b/internal/service/wafv2/web_acl.go index 4baa2533bad..b94466147d4 100644 --- a/internal/service/wafv2/web_acl.go +++ b/internal/service/wafv2/web_acl.go @@ -65,7 +65,6 @@ func ResourceWebACL() *schema.Resource { }, "application_integration_url": { Type: schema.TypeString, - Optional: true, Computed: true, }, "association_config": associationConfigSchema(), @@ -237,8 +236,8 @@ func resourceWebACLRead(ctx context.Context, d *schema.ResourceData, meta interf } webACL := output.WebACL - arn := aws.StringValue(webACL.ARN) - d.Set("arn", arn) + d.Set("application_integration_url", output.ApplicationIntegrationURL) + d.Set("arn", webACL.ARN) d.Set("capacity", webACL.Capacity) if err := d.Set("association_config", flattenAssociationConfig(webACL.AssociationConfig)); err != nil { return diag.Errorf("setting association_config: %s", err) @@ -258,7 +257,6 @@ func resourceWebACLRead(ctx context.Context, d *schema.ResourceData, meta interf d.Set("description", webACL.Description) d.Set("lock_token", output.LockToken) d.Set("name", webACL.Name) - d.Set("application_integration_url", output.ApplicationIntegrationURL) rules := filterWebACLRules(webACL.Rules, expandWebACLRules(d.Get("rule").(*schema.Set).List())) if err := d.Set("rule", flattenWebACLRules(rules)); err != nil { return diag.Errorf("setting rule: %s", err) diff --git a/website/docs/r/wafv2_web_acl.html.markdown b/website/docs/r/wafv2_web_acl.html.markdown index daeea1e09b5..b80fe049431 100644 --- a/website/docs/r/wafv2_web_acl.html.markdown +++ b/website/docs/r/wafv2_web_acl.html.markdown @@ -1052,8 +1052,8 @@ The `uri_path` block supports the following arguments: This resource exports the following attributes in addition to the arguments above: +* `application_integration_url` - The URL to use in SDK integrations with managed rule groups. * `arn` - The ARN of the WAF WebACL. -* `application_integration_url` - The URL to use in SDK integrations with managed rule groups * `capacity` - Web ACL capacity units (WCUs) currently being used by this web ACL. * `id` - The ID of the WAF WebACL. * `tags_all` - Map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block).