Skip to content

CloudFormation: DescribeStackEvents has no backing event model #501

Closed

Description

@scttfrdmn

Summary

DescribeStackEvents returns UnsupportedOperation (HTTP 400). The CloudFormation
wire plugin registered in v0.87.0 (#483) implements 15 operations and deliberately
scopes this one out, because there is no event model behind it to report from.

This issue records what a real model would need, so the refusal is a stated boundary
rather than an omission.

Why it was scoped out rather than answered

CFNStackState (emulator/betty_cfn.go) carries a single Status string, and
StackDeployer.Deploy sets it to "CREATE_COMPLETE" after every resource has been
deployed. UpdateStack overwrites it with "UPDATE_COMPLETE". Nothing records:

  • when each individual resource started or finished deploying,
  • the CREATE_IN_PROGRESS → CREATE_COMPLETE transition per resource,
  • a ResourceStatusReason for a resource that failed,
  • the stack-level CREATE_IN_PROGRESS event that precedes the resources',
  • an event ID, or any ordering among events.

Answering DescribeStackEvents from what exists would mean synthesizing a plausible
two-events-per-resource sequence with invented timestamps and invented event IDs.
That is inventing observations, which is the opposite of the provenance discipline in
CLAUDE.md and docs/fidelity.md: a consumer asserting on an event they read out of
substrate would be asserting on something substrate made up. UnsupportedOperation
is at least a signal they can see. (It is substrate's own code, not a documented
CloudFormation one — real CloudFormation has no error for an operation it implements.)

What a real model needs

  1. A per-resource event record written as each resource deploys, carrying
    EventId, StackId, StackName, LogicalResourceId, PhysicalResourceId,
    ResourceType, Timestamp, ResourceStatus, ResourceStatusReason and
    ResourceProperties. Timestamps come from the TimeController, so they are
    deterministic and replay identically.
  2. Stack-level bracket events — CREATE_IN_PROGRESS on the stack before the
    first resource and CREATE_COMPLETE after the last — which is what the CLI's
    wait and most consumer polling loops key off.
  3. A decision about the in-progress window. CreateStack deploys synchronously
    and returns already complete, so a truthful event log has every event at the same
    simulated instant unless the deployer advances the clock between resources.
    Whether it should is a design question: advancing makes the log look like real
    CloudFormation's, but it also means a stack deployment moves the shared clock,
    which every other plugin observes.
  4. Reverse-chronological ordering and NextToken pagination, which the operation
    documents.
  5. Failure events. DeployedResource.Error already records a per-resource
    failure, so a CREATE_FAILED event with the error as its
    ResourceStatusReason is the one part that has a real source today.
  6. Retention. Real CloudFormation keeps events for 90 days; substrate would keep
    them for the life of the stack record, and deleting a stack currently deletes its
    state entirely.

Alternative worth considering

Substrate already records every API call in the event store. A stack deployment is a
sequence of dispatched requests through the registry, each of which is an event with
a real timestamp. DescribeStackEvents could be derived from the event log
filtered to the deployment's stream rather than from a second parallel record — which
would make the events genuinely observed rather than modelled, and would fit the
event-sourced design better than a hand-maintained event list.

That is the more interesting design and the reason this is filed as its own issue
rather than as a small follow-up.

Acceptance criteria

  • A decision recorded on whether events are derived from the event store or
    recorded separately.
  • DescribeStackEvents returns events for a created stack, newest first.
  • A resource that fails to deploy produces a CREATE_FAILED event carrying its
    error as ResourceStatusReason.
  • UpdateStack and DeleteStack produce their own events.
  • NextToken pagination works.
  • Timestamps come from the TimeController and a replayed run produces
    byte-identical events.
  • The DescribeStackEvents refusal test in
    emulator/cloudformation_plugin_test.go is replaced knowingly, and
    docs/services.md's "DescribeStackEvents is not supported" section is removed.

Activity

  1. added
    type: feature
    area: cloudformation
    on Aug 2, 2026
  2. scttfrdmn commented on Aug 3, 2026

    @scttfrdmn
    OwnerAuthor

    Left unmilestoned deliberately while the rest of the CloudFormation cluster was swept into v0.88.0 (#521, #522, #526, #527) and v0.89.0 (#508, #518, #520). Recording that as a decision rather than an oversight.

    Why it is not in either release. Point 3 of this issue's own "what a real model needs" is an unanswered design question, not implementation work: CreateStack deploys synchronously and returns already complete, so a truthful event log has every event at the same simulated instant unless the deployer advances the clock between resources — and if it does, a stack deployment moves the shared clock that every other plugin observes. That question is not CloudFormation's alone. #514 asks for the same thing from the other end (EC2 instance transitions are instantaneous, so pending/stopping/shutting-down are never observable), and both want the same answer: how does substrate make a multi-step operation's intermediate states observable on a deterministic clock without a completed operation having silently advanced time for everyone. Answering it once, in a release where it is the subject, gives both issues the same semantics. Answering it inside this issue makes CloudFormation's stack events the precedent for every other plugin's transitions by accident.

    There is also a sequencing reason. Point 6 says substrate would keep events for the life of the stack record and that deleting a stack currently deletes its state entirely — and #518 (v0.89.0) changes what stack deletion does. An event model built before the delete path exists gets its retention question answered twice.

    What has not changed. The refusal is still UnsupportedOperation and still a stated boundary. The alternative in the issue — deriving events from the event store, which already records every dispatched request with a real TimeController timestamp — remains the more promising route precisely because it invents nothing, and v0.87.1's #519 work strengthened it: dispatch now derives a per-resource failure from either plugin error convention and records the plugin's own error code, so a derived CREATE_FAILED event would carry a real ResourceStatusReason (InvalidBucketName: The specified bucket is not valid.) rather than a bare status. Point 5's "the one part that has a real source today" now has a better source than when this was filed.

    It will be milestoned once the clock-visibility question has an answer, and #514 is the natural place to settle it.

  3. scttfrdmn commented on Aug 3, 2026

    @scttfrdmn
    OwnerAuthor

    One update, since v0.89.0's plan settles a question this issue was waiting on.

    v0.89.0 (#518) makes stack-record retention explicit: a fully successful
    DeleteStack removes the stack:<name> record and its name index, while a sweep that
    fails any resource delete persists DELETE_FAILED and keeps the record — a stack
    that reports DELETE_FAILED and then vanishes from DescribeStacks is a worse lie than
    the resource leak it was reporting. So "is there still a stack to hang events off after a
    delete?" now has an answer: yes for a failed delete, no for a successful one, and an
    event model needs to store events under a key that outlives the stack record if
    DescribeStackEvents is to answer for a completed deletion at all.

    That leaves the clock-visibility question shared with #514 as this issue's only
    remaining blocker: whether CREATE_IN_PROGRESS/DELETE_IN_PROGRESS are ever observable
    in substrate, or whether every transition is instantaneous and the event log therefore
    records only terminal states. #514 is status: needs-design on the same question for EC2
    instance states, and answering it once for both is better than twice differently.

    Still unmilestoned, deliberately.

  4. scttfrdmn commented on Aug 5, 2026

    @scttfrdmn
    OwnerAuthor

    #562 is now a second consumer for this issue, so its priority is no longer only its own.

    #562 (stack service role, scheduled for v0.92.0) has an acceptance criterion requiring "a StackEvent whose ResourceStatusReason names the authorization failure". That cannot be met while DescribeStackEvents is refused, so v0.92.0 will ship the same observation through DescribeStackResources' existing ResourceStatusReason (emulator/cloudformation_plugin.go:555-568, which already derives CREATE_FAILED + reason from DeployedResource.Error) and leave #562's event criterion open against this issue.

    Worth recording for whoever takes this: the authorization-denial case will already be a real, observed per-resource failure with an error code lifted from the dispatched response (cfnDispatchError, emulator/cfn_deployer.go:3958), so it is another instance of item 5 in this issue's "what a real model needs" — a status and reason that have a genuine source rather than an invented one. It does not change the central design question here (derive events from the event store vs. keep a parallel record), which remains the reason this is filed separately.

  5. scttfrdmn commented on Aug 5, 2026

    @scttfrdmn
    OwnerAuthor

    A second consumer for this. v0.92.0 shipped #562's CloudFormation service role and authorization of a stack's resource calls, and #562's remaining acceptance criterion — reporting a denied resource call as a StackEvent — is blocked here. So this is no longer wanted only on its own merits; #562 cannot close without it, and it has moved to the v0.93.0 milestone for that reason.

    What v0.92.0 did instead, which bounds the gap: a refused resource call surfaces as CREATE_FAILED with AccessDeniedException — naming the action and the resource ARN — as that resource's ResourceStatusReason in DescribeStackResources. That is enough for a consumer to act on a refused deploy today, so this is not urgent for correctness; it is the difference between per-resource status and an ordered event history.

    Nothing in v0.92.0 pre-empts the design question here (derive from the event store vs. keep a parallel record), which is deliberate — building an event model to satisfy one checkbox would have decided this issue as a side effect. One new data point for it, though: the event log now records a stack's resource calls under their real operation names (#572) and includes the refused call as well as the ones that succeeded, so a derive-from-the-event-store approach has more to work with than it did when this was filed.

  6. scttfrdmn commented on Aug 9, 2026

    @scttfrdmn
    OwnerAuthor

    The design decision this issue asks for

    The first acceptance criterion is "a decision recorded on whether events are derived
    from the event store or recorded separately". The answer is neither as filed: they
    are derived at read time from the stack record. Two measurements ruled out the
    event-store route this issue named as its preferred one.

    A recorded Event cannot name a resource. EventStore.RecordRequest
    (emulator/eventstore.go:310-319) builds an event from the request context and the
    operation, and never copies reqCtx.Metadata onto it. So the log knows
    s3:CreateBucket at T but not which logical resource that was — and
    LogicalResourceId is what every useful StackEvent carries. Deriving from the log
    would mean guessing which recorded call belonged to which resource, which invents more
    than reading the record does.

    The event store is disabled for in-process callers. RecordEvent returns early
    when !config.Enabled (eventstore.go:257), and the CFN plugin substitutes
    NewEventStore(EventStoreConfig{Enabled: false}) when no store is passed
    (cloudformation_plugin.go:114-117). An emulator.Client test would therefore have
    seen an empty list for a stack that plainly deployed.
    TestCFNEvents_DerivesWithoutAnEventStore is the regression guard on this: a plugin
    initialized with no event store still reports events.

    The stack record carries the logical ID, physical ID, type and error for each resource,
    so it can answer without guessing. cfnResourceStatus is now shared with
    DescribeStackResources, so the two views cannot disagree about whether a resource
    failed.

    The clock question was already settled in-repo

    This issue (and #514) held that "does a deploy advance the shared clock" was open, and
    waited on it. It is settled, and settled against the assumption it was filed under:
    TimeController.Now() is simBaseline + (wall_now − wall_baseline) × scale, so
    simulated time advances with real wall time. emulator/sqs_control.go:20-27 already
    draws the conclusion explicitly — a duration-based window "would make 'still missing'
    assertions wall-clock dependent — which no test here may be" — and uses counted
    observations instead.

    So no new clock semantics were needed, only application of that existing conclusion:
    resource events are terminal only, all events in a deploy share the record's
    instant, and ordering is carried by position (reverse deployment order) rather than by
    manufactured timestamps. #514 is therefore not a blocker for this issue and stands
    on its own EC2 merits.

    What shipped

    • DescribeStackEvents answers 200 for every stack, newest first, paginated at 100
      with a NextToken. The operation has no MaxResults parameter — the CLI's
      --max-items is client-side — so a token loop is the only way to page.
    • A stack's own events bracket the operation (CREATE_IN_PROGRESS / UPDATE_IN_PROGRESS
      / DELETE_IN_PROGRESS and the terminal status); each resource gets its one terminal
      event. No per-resource CREATE_IN_PROGRESS is emitted, because substrate never
      observed one.
    • EventId is deterministic: {LogicalId}-{ResourceStatus}-{Timestamp} for a resource,
      which is the form AWS's own sample response returns, and a UUID derived from the stack
      ARN, status and timestamp for a stack event. A replayed stack reports byte-identical
      events.
    • A stack deleted successfully is gone from the record, so DescribeStackEvents on it
      reports ValidationError, matching DescribeStacks (point 6 of this issue). A stack
      whose delete failed remains, and its events name the resource holding it.
    • The docs/services.md "DescribeStackEvents is not supported" section is deleted and
      replaced with what the model is, per this issue's own criterion.

    Mutation testing ran 12 mutants over the derivation: 11 caught. The one survivor was a
    genuine defect rather than a test gap — a sort.SliceStable by timestamp that could
    never reorder anything, since the list is already non-decreasing in time when built. It
    was removed rather than covered by a test for an unreachable branch.

  7. added this to the v0.95.0 milestone on Aug 9, 2026
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

    area: cloudformationfidelitytype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions