Skip to content

feat(cloudfront): scaffold service + distributions, invalidations, tags#778

Merged
vieiralucas merged 5 commits intomainfrom
worktree-batch1-cloudfront-distributions
Apr 26, 2026
Merged

feat(cloudfront): scaffold service + distributions, invalidations, tags#778
vieiralucas merged 5 commits intomainfrom
worktree-batch1-cloudfront-distributions

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 26, 2026

Summary

First batch of CloudFront control-plane support: 29 ops covering distribution CRUD with ETag/If-Match concurrency, invalidations, tags, alias and web ACL associations, and the read-only "by predicate" listings. Adds the fakecloud-cloudfront crate, REST-XML routing, and a typed DistributionConfig model that round-trips origins, cache behaviors, custom error responses, viewer certificates, geo restrictions, and tenant config via quick-xml.

The remaining 138 CloudFront ops (OAC, cache/origin/response policies, Functions, key groups, OAIs, streaming distributions, field-level encryption, real-time logs, monitoring, VPC origins, anycast IP lists, trust stores, distribution tenants, connection groups/functions, resource policy) ship in subsequent batches.

Highlights

  • Idempotent CallerReference enforcement returns DistributionAlreadyExists (matches AWS).
  • UpdateDistribution/DeleteDistribution enforce If-Match; DeleteDistribution rejects enabled distributions with DistributionNotDisabled.
  • CreateInvalidation returns Completed immediately so tests don't need to poll, consistent with how ECS/RDS lifecycles behave in fakecloud.
  • cloudfront registered on its SigV4 service name and added to the REST-XML services list in fakecloud-core.
  • aws-sdk-cloudfront wired into fakecloud-testkit behind sdk-clients.
  • README, services index, and per-service cloudfront.md page are updated to reflect the new service and which surfaces remain for follow-up batches.

Test plan

  • cargo test -p fakecloud-cloudfront — 15/15 unit tests
  • cargo test -p fakecloud-e2e --test cloudfront — 6/6 SDK e2e (incl. complex DistributionConfig round-trip)
  • cargo test -p fakecloud-conformance --test cloudfront — 14/14 SDK conformance pinned to Smithy checksums
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo fmt --check

Summary by cubic

Adds the first batch of CloudFront control-plane support (29 ops): distribution CRUD with ETag/If-Match, invalidations, tags, and alias/web ACL associations. Registers cloudfront as a REST-XML global service, adds fakecloud-cloudfront, updates tests/docs, and wires reset.

  • New Features

    • Distribution lifecycle: create/get/update/delete with idempotent CallerReference; If-Match for update/delete; delete blocked when enabled.
    • Tags: CreateDistributionWithTags, ListTagsForResource, TagResource, UntagResource.
    • Invalidations: CreateInvalidation returns Completed immediately.
    • Read-only listings: by alias and by web ACL.
    • SDK/tests: add aws-sdk-cloudfront; 15 unit, 6 e2e, 14 conformance.
    • Docs: README, services index, and website page.
  • Bug Fixes

    • Escape XML metacharacters in hand-built REST-XML responses; add xml_escape unit test.
    • Enforce CallerReference validation in CopyDistribution (reject empty).
    • Wire CloudFront into /_fakecloud/reset to clear per-service/per-account state; align with core response API via body_stream.
    • Remove conflicting --paths flag from the CloudFront CLI snippet in docs.

Written for commit dcf71ea. Summary will update on new commits.

First batch of CloudFront control-plane support: 29 ops covering distribution
CRUD with ETag/If-Match concurrency, invalidations, tags, alias and web ACL
associations, and the read-only "by predicate" listings. The remaining 138 ops
(OAC, cache/origin/response policies, Functions, key groups, OAIs, streaming
distributions, field-level encryption, real-time logs, monitoring, VPC origins,
anycast IP lists, trust stores, distribution tenants, connection
groups/functions, resource policy) ship in subsequent batches.

* `fakecloud-cloudfront` crate with REST-XML routing, typed `DistributionConfig`
  model that round-trips origins, cache behaviors, custom error responses,
  viewer certificates, geo restrictions, and tenant config via `quick-xml`
* `cloudfront` registered on the `cloudfront` SigV4 endpoint, added to the
  REST-XML services list in `fakecloud-core`
* Idempotent `CallerReference` enforcement returns `DistributionAlreadyExists`
* `UpdateDistribution` and `DeleteDistribution` enforce `If-Match`;
  `DeleteDistribution` rejects enabled distributions
* `CreateInvalidation` returns `Completed` immediately so tests don't need to
  poll, mirroring the deterministic shape used by ECS/RDS lifecycles
* 15 unit tests, 6 SDK e2e tests (incl. complex `DistributionConfig`
  round-trip), 14 conformance tests pinned to AWS Smithy checksums
* `aws-sdk-cloudfront` wired into `fakecloud-testkit` behind `sdk-clients`
* Audit mapping + service-map + update script include `cloudfront`
* README, services index, and per-service `cloudfront.md` page reflect the new
  service and call out which surfaces remain for follow-up batches
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 25 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="crates/fakecloud-cloudfront/src/service.rs">

<violation number="1" location="crates/fakecloud-cloudfront/src/service.rs:466">
P2: `CopyDistribution` skips caller-reference validation, so it can create distributions with an empty `CallerReference` that other distribution write paths reject.</violation>

<violation number="2" location="crates/fakecloud-cloudfront/src/service.rs:879">
P1: Response XML includes unescaped user-provided fields, which can produce malformed XML for valid inputs containing XML metacharacters.</violation>
</file>

<file name="crates/fakecloud-server/src/main.rs">

<violation number="1" location="crates/fakecloud-server/src/main.rs:1956">
P2: CloudFront state is registered but not wired into reset handling, so reset endpoints won’t clear CloudFront resources.</violation>
</file>

<file name="website/content/docs/services/cloudfront.md">

<violation number="1" location="website/content/docs/services/cloudfront.md:61">
P2: The smoke-test `create-invalidation` command passes both `--paths` and `--invalidation-batch`, but these options are mutually exclusive in AWS CLI.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread crates/fakecloud-cloudfront/src/service.rs Outdated
Comment thread crates/fakecloud-cloudfront/src/service.rs
Comment thread crates/fakecloud-server/src/main.rs Outdated
Comment thread website/content/docs/services/cloudfront.md Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2026

- Escape XML metacharacters in user-supplied fields (Comment, WebACLId,
  WebACLArn, tag keys/values, distribution Id/ARN/Status/DomainName,
  invalidation Id/Status) when emitting hand-rolled XML response bodies.
  Quick-XML's serde-driven path already escapes correctly; the leak was
  in the manual `format!`-based responses for `Distribution`,
  `DistributionList`, `InvalidationList`, `Tags`,
  `Associate/DisassociateDistributionWebACLResult`. Add an `xml_escape`
  unit test that round-trips `&<>` in both Tags and the Comment field
  and asserts they never appear unescaped in either response shape.
- Validate `CallerReference` in `CopyDistribution`. The other two write
  paths (Create / CreateWithTags) reject empty references; copy was
  taking whatever the caller sent and persisting an empty
  `CallerReference` on the new distribution.
- Wire CloudFront state into `ResetState` so `/_fakecloud/reset` and the
  per-service / per-account reset endpoints clear distributions,
  invalidations, and tags alongside every other service. Required
  hoisting `cloudfront_state` ahead of `let reset_state = …`.
- Drop the conflicting `--paths` flag from the smoke-test snippet in
  `cloudfront.md`; AWS CLI rejects `--paths` together with
  `--invalidation-batch`.
@vieiralucas vieiralucas merged commit 17e77f3 into main Apr 26, 2026
37 of 38 checks passed
@vieiralucas vieiralucas deleted the worktree-batch1-cloudfront-distributions branch April 26, 2026 12:41
vieiralucas added a commit that referenced this pull request Apr 26, 2026
…ings

Audit was already failing on PR #778 (16 missing tests across
AssociateDistributionWebACL, CopyDistribution, CreateDistributionWithTags,
DisassociateDistributionWebACL, and 12 ListDistributionsBy* variants).
Pre-existing red CI surfaces here — not new with batch 2 — but per
'never merge red CI' policy, fix on the spot.

- Add 16 conformance tests with Smithy checksums covering all the
  by-X listings + WebACL/Copy/WithTags ops.
- Fix list_distributions_by response root mapping per AWS spec:
  cache/origin-request/response-headers/key-group/vpc-origin policy
  IDs return DistributionIdList; owned-resource returns
  DistributionIdOwnerList; trust-store/web-acl/anycast/connection-mode/
  connection-function/realtime-log return DistributionList.
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