Skip to content

CloudFront: UpdateDistribution should reject an incomplete DistributionConfig (IllegalUpdate / missing-field errors) #1271

Closed

Description

@scttfrdmn

What real CloudFront does

UpdateDistribution replaces the entire configuration and rejects one that omits fields
the caller never set, one field per 400. I hit these in sequence against a real account
today, each a separate round trip:

IllegalUpdate:   Aliases are missing for the resource
IllegalUpdate:   The 'OriginCustomHeaders' field is missing
InvalidArgument: The parameter SmoothStreaming flag is missing

CreateDistribution happily defaults all of them, which is what makes this a trap: a config
that creates fine cannot be sent back. The correct pattern is read-modify-write —
GetDistributionConfig, overwrite only your own fields, UpdateDistribution — and the errors
above are how you discover that.

Why it's in scope

Purely API-observable: request validation and error codes, no resource internals. It sits in
the Implemented → Partial gap for UpdateDistribution — the nominal path works, but the
validation that teaches callers the right shape is missing.

Why I'd value it

I wrote a CloudFront deployer for foray with hand-written
fakes. The fakes accepted a from-scratch config, so my tests were green and my model was
self-consistent — and wrong. I found all three only on a live deploy, at one field per
round trip. An emulator that enforced them would have caught the whole class offline.

Suggested fidelity

On UpdateDistribution, require the fields real CloudFront requires and answer with the same
code/message. From what I hit, at minimum:

  • Aliases present (even {Quantity: 0}) → else IllegalUpdate: Aliases are missing for the resource
  • each Origins.Items[] carrying CustomHeaders → else IllegalUpdate: The 'OriginCustomHeaders' field is missing
  • each cache behaviour carrying SmoothStreaming → else InvalidArgument: The parameter SmoothStreaming flag is missing

There are likely more in the same family (I stopped once mine passed): OriginPath,
TrustedSigners/TrustedKeyGroups, LambdaFunctionAssociations, FunctionAssociations,
FieldLevelEncryptionId, Compress, ConnectionAttempts/ConnectionTimeout, and for a custom
origin OriginReadTimeout/OriginKeepaliveTimeout. The AWS API reference marks required vs
optional per field, and per your fidelity policy that's the source of truth rather than my
sample.

Related, and more valuable to me if cheap

DeleteDistribution's preconditions, which are the other half of what bit me:

  • an enabled distribution → DistributionNotDisabled
  • a stale If-Match → PreconditionFailed
  • Status transitioning InProgress → Deployed over the simulated clock, so the
    disable → wait → delete loop can be exercised deterministically (Stateful + Fault-aware)

I modelled all three in my own fakes to test the teardown dance; having them in substrate would
mean not modelling them.

Reproduction

internal/deploy/cloudfront.go in foray builds the desired config and, on convergence,
read-modify-writes it (converge). Reverting that to send d.config(...) directly reproduces
the first error against real AWS immediately.

Activity

  1. scttfrdmn commented on Sep 26, 2026

    @scttfrdmn
    OwnerAuthor

    Verified against origin/main (57ab1d0, post-v0.120.0) — the claims above hold at current main: UpdateDistribution/DeleteDistribution are implemented, and none of IllegalUpdate, DistributionNotDisabled or PreconditionFailed appear in the plugin.

    One thing I missed when filing: the Origin Access Control operations are absent entirely (ListOriginAccessControls, CreateOriginAccessControl, GetOriginAccessControl, DeleteOriginAccessControl), as is CreateDistributionWithTags. For foray those block more than the validation gaps do — without OAC its CloudFront deploy can't run against substrate at all, since a private bucket behind a distribution is the whole point.

    Rolled up with the rest in #1274.

  2. added this to the v0.122.0 milestone on Sep 26, 2026
  3. scttfrdmn commented on Sep 26, 2026

    @scttfrdmn
    OwnerAuthor

    Triaged to v0.122.0. Both halves are in scope and the second half is the one with the
    dependency, so a note on each.

    The required-field validation is cheap and lands as written: it is a rule about the request
    body, so substrate can enforce it without recording any more of a distribution than it does today.
    The three codes you hit — IllegalUpdate: Aliases are missing for the resource,
    IllegalUpdate: The 'OriginCustomHeaders' field is missing,
    InvalidArgument: The parameter SmoothStreaming flag is missing — will be sourced the way you
    suggest: the API reference's required/optional marking per member decides the set, and your sample
    decides nothing except which three are certain. Where a message comes from your observation rather
    than from the model it gets recorded as such in the release's ## Provenance section, since the
    exact wording is not published anywhere.

    The delete preconditions need groundwork, which is the real reason this is not a one-afternoon
    issue:

    • PreconditionFailed on a stale If-Match needs a per-distribution ETag, and substrate emits no
      ETag for a distribution anywhere today.
    • DistributionNotDisabled is straightforward — Enabled is already recorded.
    • InProgress → Deployed over the simulated clock is the piece that makes the
      disable → wait → delete loop assertable, and it is worth having for exactly the reason you give:
      the loop exists to handle a transition, so a test that never observes one is not testing it.

    One more thing this issue picks up, because it is the natural home for it: a distribution starts
    recording its Origins.
    Read-modify-write is unfalsifiable until GetDistributionConfig answers
    back something a caller could have written — today it answers two of DistributionConfig's five
    required members, for the reason docs/services.md sets out under "A configuration is not a
    distribution". Recording the origins here also unblocks OriginAccessControlInUse/409, which #1277
    deliberately leaves out for want of exactly that.

    #1277 (the OAC set) is going first, since #1274 names it as the blocker; this follows it.

  4. added a commit that references this issue on Sep 26, 2026
  5. scttfrdmn commented on Oct 4, 2026

    @scttfrdmn
    OwnerAuthor

    Shipped in #1383. UpdateDistribution now replaces the configuration rather than merging, and refuses the three omissions in the order and wording observed here:

    • IllegalUpdate "Aliases are missing for the resource";
    • IllegalUpdate "The 'OriginCustomHeaders' field is missing";
    • InvalidArgument "The parameter SmoothStreaming flag is missing".

    CreateDistribution fills in those three defaults, so a read-modify-write through GetDistributionConfig round-trips. Distributions carry an ETag that update and delete require as If-Match, and deleting an enabled distribution is DistributionNotDisabled. CloudFormation's stack delete now disables first. The three messages and their order are recorded as observed provenance in docs/services.md.

    One part of the follow-up folded in here is not built: an observable InProgress → Deployed window, which a deploy waiter polls. It needs a seedable progression, and is split out as #1381. Closing on the rest.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions