pulumi-aws icon indicating copy to clipboard operation
pulumi-aws copied to clipboard

WAFv2 creation with Go - Error creating WAFv2 WebACL

Open Graham-Beer opened this issue 3 years ago • 1 comments

Looking to get started with building a Waf v2 using the Go pulumi Library. Started to look at the code examples for Go from the page https://www.pulumi.com/docs/reference/pkg/aws/wafv2/webacl/. When trying to execute the examples from the page, I get an error which relates to the "action" and "defaultAction" fields.

Steps to reproduce

To recreate the problems, build a new pulumi project and copy the code from the page into main.go. Running a pulumi up -y gives the errors:

" aws:wafv2:WebAcl (example): error: 1 error occurred: * Error creating WAFv2 WebACL: InvalidParameter: 1 validation error(s) found. - missing required field, CreateWebACLInput.DefaultAction. " And also

"aws:wafv2:RuleGroup (example): error: 1 error occurred: * Error creating WAFv2 RuleGroup: WAFInvalidParameterException: Error reason: You have used none or multiple values for a field that requires exactly one value., field: RULE_ACTION, parameter: RuleAction(block=null, allow=null, count=null) { RespMetadata: { StatusCode: 400, RequestID: "e1328aa8-2720-47f6-b8ee-144e773a63f9" }, Field: "RULE_ACTION", Message_: "Error reason: You have used none or multiple values for a field that requires exactly one value., field: RULE_ACTION, parameter: RuleAction(block=null, allow=null, count=null)", Parameter: "RuleAction(block=null, allow=null, count=null)", Reason: "You have used none or multiple values for a field that requires exactly one value." } " Attached below are two screenshots displaying the errors described above:

image and image

This is preventing creation of a Waf v2 in AWS.

Graham-Beer avatar Sep 22 '21 14:09 Graham-Beer

@Graham-Beer

While the example from https://pulumi.com/docs does indeed fail, the example can be fixed with a couple of small tweaks:

  1. Replace
OverrideAction: &wafv2.WebAclRuleOverrideActionArgs{
	Count: nil,
},

with

OverrideAction: &wafv2.WebAclRuleOverrideActionArgs{
	Count: &wafv2.WebAclRuleOverrideActionCountArgs{},
},
  1. Replace
DefaultAction: &wafv2.WebAclDefaultActionArgs{
	Allow: nil,
},

with

DefaultAction: &wafv2.WebAclDefaultActionArgs{
	Allow: &wafv2.WebAclDefaultActionAllowArgs{},
},

You should be able to successfully execute pulumi up at this point.

phillipedwards avatar Sep 28 '21 21:09 phillipedwards