Skip to content

feat(tagging): reach an ACM certificate and a CloudFront distribution (#835) - #920

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/tagging-acm-cloudfront-rows
Sep 16, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/tagging-acm-cloudfront-rows

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Two of the eleven rows of #835: an ACM certificate and a CloudFront distribution are now reachable through the Resource Groups Tagging API. Nine remain, so this PR carries no closing keyword — part of #835.

Both ARNs fell to resolveARN's default arm and answered an InternalServiceException FailedResourcesMap entry, while both services tag the resource perfectly well through their own calls. A tag was therefore writable through one API and invisible to the other, which is the split #765 exists to close.

Scope

Both types are on AWS's authoritative list: the tagging guide's welcome page names AWS Certificate Manager and Amazon CloudFront among the services TagResources/UntagResources support. The same page settles the other half at a stroke — "the GetResources, GetTagKeys, and GetTagValues operations support all resource types" — so a missing scanner is a gap in substrate rather than a boundary of AWS's. docs/services.md previously said AWS published no list at all; that is corrected, along with the note that the per-service list truncates alphabetically at IAM, so a type absent from it is unlisted, not refused.

Each row is three parts

A resolver arm, so TagResources/UntagResources reach the record; a merge arm through mergeRecordStringMapTags, so the write edits the tags member of the raw JSON and leaves every other member untouched; and a scanner, so GetResources reports it. None substitutes for the others — an arm without a scanner leaves the resource writable and invisible.

Both resolvers share the key builder the owning service already uses, so neither API can address a resource the other would not. CloudFront's goes through cfParseDistributionARN, the parser its own three tagging operations use as of #918, so the account comes from the ARN at the tagging API too and a foreign-account ARN naming the caller's own distribution ID is refused.

ACM's own tag operations are not an instance of #918

They key from the calling request, and that is correct. acmCertKey embeds the whole certificate ARN alongside the account and Region the ARN itself names, so a lookup keyed by the caller's account can only ever find a record whose ARN names that same account — there is no key at which the two disagree. Changing them to key from the ARN would introduce the cross-account reach the redundancy forecloses. I had planned that change and reversed it before writing any code; the analysis is recorded in emulator/acm_tags.go's preamble and in docs/services.md rather than acted on.

Guards and refusals

Each merge sits behind a kind guard testing a colon-terminated prefix: cert is a prefix of cert_arns and cfdist of cfdist_ids, so a bare-prefix test would report an index key taggable and merge a tags member into a JSON array of identifier strings. CloudFront's four key kinds now have one producer each — the two invalidation keys were inline concatenation at five sites — so the guard cannot fall out of step with the keys actually written.

An ARN of any other resource type is refused rather than resolved to a reachable one (#910's anchored-segment rule):

  • ACM scopes its three tag operations to one type in prose — "This action applies only to the certificate resource type" — while the published CertificateArn pattern does not restrict the resource portion, so the restriction is the prose's. An ACME endpoint ARN and anything nested under a certificate are refused.
  • CloudFront's reference draws the boundary itself — "You can tag distributions, but you can't tag origin access identities or invalidations" — and substrate stores invalidations in the same namespace, so an invalidation ARN nested under the caller's real distribution is a reachable-looking target. So is streaming-distribution/{the caller's own ID}, which is exactly what an unanchored substring match finds.

The CloudFront Region attribution

GetResources reports a distribution in us-east-1 only. CloudFront is global and its ARNs carry an empty Region segment, but GetResources is per-Region, so a global resource has to be attributed to exactly one Region or every Region's call would report it — and TagResources states "you can only tag resources that are located in the specified AWS Region for the AWS account".

Provenance split: which Region it is, is AWS's; that the gate exists at all is substrate's reading, since AWS publishes the attribution and not a GetResources rule. CloudFront's own ListDistributions keeps answering from any Region — that is what a global service does, and the per-Region attribution belongs to the tagging API alone.

Tests

Twelve tests in emulator/tagging_acm_cloudfront_test.go, all over the wire, and every tag written through the tagging API is read back through the owning service's own tag call rather than out of the state store (#765's standing rule — the only thing that distinguishes a tag that landed on the right record from one that landed on a phantom key and answered 200).

  • cross-readability, both directions, both services;
  • UntagResources removes only the named keys — the damaging direction;
  • the scanner half, plus that the cert_arns: index is never reported as a resource with an empty ARN;
  • wrong-type refusals: 6 ACM subcases, 5 CloudFront subcases, the latter carrying the caller's real distribution ID;
  • foreign-account ARNs refused in both directions, with the caller's own resource asserted untouched afterwards.

The Region gate is asserted against a live control rather than an empty response: an ACM certificate requested in us-west-2 is reported there while the distribution is not. Without it, "the distribution is absent from us-west-2" would pass just as well against an endpoint that scanned nothing.

Negative control: with the two scanner descriptors removed and the two switch arms renamed, 9 of 12 tests fail. The 3 that still pass are pure-refusal cases, which also refused via the default arm.

Verification

The nine-command gate passes from the repo root: gofmt/go build/go vet clean, golangci-lint 0 issues, make test and GOTOOLCHAIN=go1.26.6 make test green, make docs-reference docs-reference-check docs-versions authz-reference-check clean, npm --prefix docs run build clean, and go vet -C test/e2e ./... && go test -C test/e2e ./... green. Coverage holds the baseline exactly: 84.1% emulator / 83.6% total.

Also in this PR

docs/services.md loses a claim the tree no longer had — "The Resource Groups Tagging API cannot reach a CloudFront distribution" — and the ACM operations table gains RemoveTagsFromCertificate, ListTagsForCertificate and RenewCertificate, which have been dispatched for some time and were missing from it.

Filed separately, deliberately not folded in

All three ACM tag operations publish ResourceNotFoundException at HTTP 400 and substrate answers 404; InvalidArnException/400 is unmodelled. That is a status-code defect independent of reachability and gets its own issue.

…#835)

Both ARNs fell to resolveARN's default arm and answered an
InternalServiceException FailedResourcesMap entry, while both services tag the
resource perfectly well through their own calls -- so a tag was writable
through one API and invisible to the other. Two of the eleven rows of #835.

Each row is three parts and none substitutes for the others: a resolver arm, a
raw-JSON merge arm behind a colon-terminated kind guard, and a scanner. Both
resolvers share the key builder the owning service already uses, so neither API
can address a resource the other would not.

ACM's own tag operations key from the calling request and that is correct, not
an instance of the #918 defect: acmCertKey embeds the whole ARN alongside the
account and Region the ARN names, so no key exists at which the two disagree.
Recorded rather than "fixed".

GetResources reports a CloudFront distribution in us-east-1 only. Which Region
is AWS's; that the gate exists at all is substrate's reading.
@scttfrdmn scttfrdmn added this to the v0.117.0 milestone Sep 16, 2026
@scttfrdmn
scttfrdmn merged commit ed7c7e7 into main Sep 16, 2026
16 checks passed
@scttfrdmn
scttfrdmn deleted the feat/tagging-acm-cloudfront-rows branch September 16, 2026 01:10
@codecov

codecov Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.42308% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/tagging_plugin.go 84.37% 10 Missing ⚠️
emulator/acm_tags.go 95.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant