Repository navigation
Description
v0.114.0's #827 work fixed CloudFormation's WAFv2 web-ACL ARN to derive its scope segment from the Scope property (cfn_resources_v32.go:71, strings.ToLower(scope)). The WAFv2 plugin was not touched, and it hardcodes regional:
emulator/wafv2_plugin.go:132—createWebACLemulator/wafv2_plugin.go:448—createIPSet
Those two plus the CloudFormation site are the only arn:aws:wafv2 literals in non-test code. So:
- The same logical web ACL reports two different ARNs depending on whether CloudFormation or the WAFv2 API created it.
- A
CLOUDFRONTweb ACL or IP set created through the API still reports an ARN naming a scope it does not have — the exact defect cfn: Ref returns the physical ID for every type, but AWS returns an ARN for an ELBv2 load balancer and target group #827 fixed on the other path.
An IP-set ARN is what a caller hands to IPSetReferenceStatement, and a web-ACL ARN is what AssociateWebACL takes, so a wrong scope segment is not cosmetic: it is an identifier another operation is expected to accept.
Fix
One builder, wafv2ARN(region, accountID, scope, resourceType, name, id), used by all three sites — the "one builder, so they cannot drift" structure #826 established for SQS state keys. Two implementations of an ARN are two answers, which is how this diverged in the first place.
Recorded as unverifiable
Whether a CLOUDFRONT ARN's scope segment is cloudfront is not citable. Four sources:
- The Service Authorization Reference page for WAFv2 returns an empty body.
- AWS's machine-readable Service Reference gives only the unsubstituted placeholder
arn:${Partition}:wafv2:${Region}:${Account}:${Scope}/<type>/${Name}/${Id}. API_AssociateWebACLlists the eight protectable-resource ARN formats but no web-ACL ARN.- The CloudFormation Template Reference for
AWS::WAFv2::WebACLgives the only substituted example AWS publishes anywhere —arn:aws:wafv2:us-east-1:ExampleAccountNumber:regional/webacl/exampleWebACL/exampleWebACLExampleID— and it is a REGIONAL ACL renderingregional, i.e. the lowercase of theScopevalue.
That is consistent with strings.ToLower(scope) and is not proof for CLOUDFRONT. The value of the fix is that the three sites agree; which literal they agree on is stated in wafv2ARN's doc comment as substrate's reading, not AWS's.
Acceptance criteria
- One function builds every
arn:aws:wafv2in non-test code. - A web ACL created through
CreateWebACLwithScope: CLOUDFRONTreports acloudfrontscope segment, notregional. - A web ACL created through CloudFormation and one created through the API report the same ARN shape for the same scope.
-
CreateIPSetgets the same treatment. - The
CLOUDFRONTsegment is documented as substrate's reading with the four failed sources named.
Fixed in the same PR as #755, since both are in createIPSet.
Activity