Skip to content

fix(cfn,wafv2,config): an identifier that distinguishes, a request that is checked, and two fields nothing wrote - #860

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/group-d-identifiers-and-dead-fields
Sep 14, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/group-d-identifiers-and-dead-fields

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Group D of v0.115.0. Four fixes with one shape: substrate reported an identifier that could not tell two resources apart, accepted a request it then invented the answers for, or carried a field no writer ever touched.

Closes #755
Closes #836
Closes #843
Closes #858

Also corrects two false statements about CloudFormation's stored PhysicalID — part of #837, which stays open.

AWS::ApiGateway::Method's physical ID (#843)

Every method in a stack was identified by its HTTP verb. Two methods with the same verb on different resources of one API were indistinguishable in DescribeStackResources, and because a PhysicalResourceId-only request scans every stack in the account, describe-stack-resources --physical-resource-id GET returned every GET method in every stack. !Ref resolved to the verb too.

The type joins cfnGeneratedNameTypes, so the physical ID is {stack}-{logical}-{suffix} — the shape AWS's Template Reference publishes for this type's Ref, "the method ID, such as mysta-metho-01234b567890example" — derived from account, Region, stack name and logical ID, so a redeploy reports the same value.

Two of the issue's acceptance criteria are reversed with a citation rather than implemented. They ask the API Gateway plugin to mint and return a method ID; AWS's REST API publishes none. API_Method carries the eleven configuration fields and no id, and API_PutMethod returns none. Implementing them would have invented a member AWS does not have. The plugin already keys methods by (account, Region, API, resource, verb), so there was never a service-state collision — the defect was purely in what CloudFormation reported.

It is also the one entry in that table whose bound comes from an example rather than a service limit, since the type has no name property and nothing is ever sent to a service for validation. 31 and lowercase are read off AWS's published example, which is the only evidence there is, and the table's comment says so.

Stack deletion was load-bearing on the old value. The deleter built the method's DELETE path using the physical ID as the verb, so generating an ID without changing the deleter would have left every method behind — with DeleteStack reporting no error, because a DELETE of /methods/{stack}-{logical}-{suffix} is a well-formed request for a method that does not exist. Deploy and delete now resolve the verb through one shared helper reading the declared properties, which is where the deleter already got the method's two parent IDs.

The verb is deliberately not recorded in Metadata. That is a generic Fn::GetAtt channel — any metadata key resolves under its own name — and AWS::ApiGateway::Method has no Fn::GetAtt section, so recording it there would publish an attribute AWS does not have. That is the defect this release fixes in IAM's permissions boundary; repeating it to fix an identifier would be a poor trade.

CreateIPSet refuses an incomplete request (#755)

All four of Addresses, IPAddressVersion, Name and Scope are documented Required: Yes, and substrate silently defaulted three of them. A request AWS rejects created an IP set whose scope and address family the caller never chose, then reported them back as though it had asked.

The issue's open question was which error code; AWS's own pages answer it in two parts:

  • an omitted required member → ValidationError/400, from WAFv2's Common Error Types ("Check that all required parameters are included and that values are valid");
  • a present-but-invalid value → WAFInvalidParameterException/400, which CreateIPSet's own Errors section lists.

IPAddressVersion ∈ IPV4|IPV6; Scope ∈ CLOUDFRONT|REGIONAL; Name matches ^[\w\-]+$ within 128 characters; each address is a CIDR range other than /0.

"Addresses": [] still succeeds. AWS lists it among the operation's valid example specifications while marking "Addresses": [""] INVALID, so absent and empty are distinct and the nil-to-[] normalisation had to go rather than sit beside the refusal. The generated Go SDK independently draws the same line — its validator keys on v.Addresses == nil.

Two things are recorded rather than enforced: AWS does not say an IPV4 set refuses an IPv6 CIDR, so the version and the addresses are checked independently; and WAFInvalidParameterException's three modelled members (Field, Parameter, Reason) have no published enumeration of the values Field and Reason take, so they are folded into the message rather than emitted with invented values. AWSError has no channel for them today either.

An existing test case asserting "an omitted version still defaults to IPV4" is deleted: it pinned the defect.

One builder for every WAFv2 ARN (#858)

v0.114.0 fixed CloudFormation's web-ACL ARN to derive its scope segment from Scope and left the plugin hardcoding regional at both create paths — the only other arn:aws:wafv2 literals in non-test code. So the same logical web ACL reported two different ARNs depending on which path created it, and a CLOUDFRONT resource created through the API reported a scope it does not have. An IP-set ARN is what IPSetReferenceStatement takes and a web-ACL ARN is what AssociateWebACL takes, so that is an identifier another operation is expected to accept.

All three sites go through wafv2ARN — two implementations of an ARN are two answers, which is how this diverged.

Which literal a CLOUDFRONT scope renders is unverified and documented as substrate's reading. Four sources: the Service Authorization Reference page returns an empty body; the machine-readable Service Reference gives only ${Scope}; API_AssociateWebACL lists the eight protectable-resource ARN formats but no web-ACL ARN; and the only substituted example AWS publishes anywhere is a REGIONAL ACL rendering regional. What the fix guarantees is that the three paths agree.

Two dead Tags fields on Config's shapes (#836)

ConfigurationRecorder.Tags and ConfigRule.Tags were declared json:"-" and were never assigned or read anywhere in the tree, tests included.

#836 is re-scoped, with the finding posted on the issue first. It was filed on the premise that the fields' presence meant creation-time tags were never persisted. They are: Config keeps every resource's tags in a side-car record keyed by ARN, and nine paths go through it, including creation-time tags for both PutConfigurationRecorder and PutConfigRule, which read the request's top-level Tags member where the API model puts it. Three existing tests already assert what the issue's criteria asked for.

Giving either field a real JSON tag — the issue's first criterion — would have introduced a defect: AWS's ConfigurationRecorder and ConfigRule shapes have no Tags member, and describeConfigurationRecorders serialises the record straight to the wire, so it would emit a member AWS never emits and create a second spelling of one resource's tags with only the side-car read. Their accurate doc comments move to cfgsvcSaveTags and cfgsvcTagsKey.

This is a breaking change for a Go consumer constructing either struct with a Tags field, which nothing in substrate did.

Two corrected statements (part of #837)

cfn_intrinsics.go and v0.114.0's #827 CHANGELOG entry both claimed the stored physical ID is "what a redeploy recognizes an existing resource by" and that every aws:cloudformation:* state key is built from it. Neither held:

  • deployedResource matches on logical ID with no physical-ID fallback; recognition is clearUnchangedRedeploys, whose own doc comment gives the reason the physical ID cannot be the key — a refused create returns none at all.
  • The four ELBv2 types bypass cfnResolveStampTarget entirely: cfnStampELBResource finds the record by ARN.

Both are corrected in place, and the correction is also recorded under ## [Unreleased] so the false statement does not survive in a released section while the reversal is only in a diff. The real reasons to leave PhysicalID alone — DescribeStackResources, the deletion path, drift detection, and the stamp for the types that do use it — are stronger than the two that were written down. #837 stays open.

Tests

Every new test was proved non-vacuous by reverting exactly the behaviour it exists for, one at a time:

Reverted Fails
the deleter back to dr.PhysicalID as the verb TestCFNMethodID_TheStackStillDeletes (200 after DeleteStack, not 404)
the AWS::ApiGateway::Method table entry TwoMethodsWithOneVerbReportDistinctPhysicalIDs, TwoStacksReportDifferentMethodIDs
createIPSet's three defaults all 4 omitted-member cases, all 13 invalid-value cases, and 9 e2e cases
wafv2ARN's derived segment back to "regional" TheScopeSegmentFollowsTheScope/CLOUDFRONT, TheAPIAndCloudFormationAgree, TestJourney_WAFv2CloudFrontARNNamesItsScope

emulator/cfn_apigateway_method_id_test.go — two methods with one verb report distinct physical IDs; Ref round-trips; an update does not move an ID; two stacks report different IDs; the stack deletes (proved by reading each method back through the plugin, since a clean DeleteStack cannot distinguish "deleted" from "asked to delete something else"); and the created method is still addressed by its verb while the generated ID is not.

emulator/wafv2_createipset_validation_test.go — the four omitted members, thirteen invalid values, "Addresses": [] accepted and reading back empty, a valid request keeping what it asked for, and the ARN scope segment from both creation paths on one deployer.

test/e2e/journey_wafv2_required_members_test.go — the wire tier, which proves three things the plugin tier cannot: that the refusal decodes as WAFv2's typed WAFInvalidParameterException (the #738 failure mode, where a consumer's errors.As branch never runs); that "Addresses": [] crosses the wire as an empty list rather than an absent member; and that a CLOUDFRONT ARN names its scope. The omitted-member case is a hand-built POST because the generated SDK refuses such a request client-side — which is why no Go consumer ever reached the defaulting, and why every tier that used a client shipped it green.

Verification

The nine-command gate, all clean:

gofmt -l . && go build ./... && go vet ./...        # clean
golangci-lint run ./...                             # 0 issues
make test                                           # ok
GOTOOLCHAIN=go1.26.6 make test                      # ok
GOTOOLCHAIN=go1.26.6 make coverage                  # emulator 83.9%, total 83.2%
make docs-reference docs-reference-check docs-versions authz-reference-check
npm --prefix docs run build                         # build complete
go vet -C test/e2e ./... && go test -C test/e2e ./... # ok

Coverage does not regress against the 83.8% emulator / 83.2% total baseline.

Compatibility

  • Every AWS::ApiGateway::Method's PhysicalResourceId and Ref change value, from the HTTP verb to a generated method ID. A consumer asserting Ref equals GET breaks; one looking up a method by --physical-resource-id GET stops matching every method in the account.
  • CreateIPSet starts refusing requests it used to accept. A caller relying on the REGIONAL/IPV4 defaults, or on an absent Addresses becoming [], now gets a 400.
  • A CLOUDFRONT web ACL or IP set created through the WAFv2 API reports a cloudfront scope segment where it previously reported regional.
  • ConfigurationRecorder and ConfigRule lose a Tags field. Go-source-level only; no wire change, since the field was json:"-".

…at is checked, and two fields nothing wrote

Four fixes, one shape: substrate reported a value that could not tell two
resources apart, accepted a request it then invented the answers for, or
carried a field no writer ever touched.

An AWS::ApiGateway::Method's physical ID was its HTTP verb, so two methods
with the same verb on different resources of one API were indistinguishable —
and because a PhysicalResourceId lookup scans every stack in the account, so
was every GET method everywhere. The type joins cfnGeneratedNameTypes, giving
the {stack}-{logical}-{suffix} shape AWS's own Ref example for the type has.
It is the one entry there whose bound comes from that example rather than a
service limit, because API Gateway's REST API publishes no method identifier
at all — which is also why the two acceptance criteria asking the plugin to
mint one are reversed with that citation. Deploy and delete now resolve the
verb through one shared helper reading the declared properties; the deleter
had been using the physical ID as the verb, so changing the ID without it
would have left every method behind with DeleteStack reporting success.

CreateIPSet defaulted three of its four documented-required members, so a
request AWS rejects created an IP set whose scope and address family the
caller never chose. An omitted member now answers ValidationError/400 (WAFv2's
CommonErrors) and an invalid value WAFInvalidParameterException/400 (the
operation's own Errors section), which settles the issue's open question from
AWS's pages rather than by choice. "Addresses": [] still succeeds: AWS lists
it valid while marking [""] INVALID, so absent and empty stay distinct and the
nil-to-empty normalisation had to go rather than sit beside the check.

Every arn:aws:wafv2 now comes from one builder. v0.114.0 fixed the
CloudFormation path to derive the scope segment and left the plugin hardcoding
"regional", so one logical web ACL reported two different ARNs depending on
which path created it. Which literal a CLOUDFRONT scope renders is substrate's
reading — four sources are named in wafv2ARN's doc comment, and the only
substituted example AWS publishes is a REGIONAL ACL.

ConfigurationRecorder.Tags and ConfigRule.Tags were declared json:"-" and
never assigned or read anywhere. Config's tags live in a side-car record and
work; giving either field a real tag would have emitted a member AWS's shapes
do not have and created a second spelling of one resource's tags. Their
accurate doc comments move to where the behaviour lives.

Two statements justifying why the stored PhysicalID is left alone were
checkable and neither held; both are corrected in cfn_intrinsics.go and in
v0.114.0's CHANGELOG entry.

Closes #755
Closes #836
Closes #843
Closes #858
@scttfrdmn scttfrdmn added this to the v0.115.0 milestone Sep 14, 2026
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 78b0e7f into main Sep 14, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/group-d-identifiers-and-dead-fields branch September 14, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment