Skip to content

kms: GetKeyRotationStatus omits NextRotationDate, and a key pending deletion reports its stored rotation status where AWS reports false #973

Closed

Description

@scttfrdmn

GetKeyRotationStatus publishes five response elements and substrate answers one. It also documents a
key-state behaviour substrate does not model: a key pending deletion reports false whatever its stored
setting, and the original setting is restored if the deletion is cancelled.

Found while answering #964's first acceptance criterion. Two of the five members come with #964, because a
rotation period reported without saying which key it belongs to is not a coherent body; this issue covers
what is left after that.

What AWS publishes

API_GetKeyRotationStatus' Response Syntax has five members:

{
   "KeyId": "string",
   "KeyRotationEnabled": boolean,
   "NextRotationDate": number,
   "OnDemandRotationStartDate": number,
   "RotationPeriodInDays": number
}

The page's sample response carries four of the five, omitting only OnDemandRotationStartDate:

{
    "KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab",
    "KeyRotationEnabled": true,
    "NextRotationDate": "2024-02-14T18:14:33.587000+00:00",
    "RotationPeriodInDays": 365
}

NextRotationDate is derivable, which makes it in scope for an emulator

API_EnableKeyRotation defines the period precisely enough to compute the date: "The rotation period
defines the number of days after you enable automatic key rotation that AWS KMS will rotate your key
material, and the number of days between each automatic rotation thereafter."

So the next rotation date is the enable date plus the period. Both halves become available once #964
stores the period, and the enable date is a new field on KMSKey (CreationDate is not it — a key can be
created long before rotation is enabled, and re-enabling with a new period moves the date).

This is squarely inside substrate's scope per CLAUDE.md: it is an API observation driven by the
simulated clock, not resource-internal behaviour. Nothing needs to actually rotate — and nothing should.
The key material is not modelled, so what is being reported is the schedule, which is exactly the kind
of time-ordered value a consumer's own scheduling logic would assert against.

The rotation itself must not be simulated as a side effect of clock advance. ListKeyRotations is the
operation that reports completed rotations and it is unimplemented; inventing rotation events here would
put a value in state that no operation can read, which is the mistake #964's fourth criterion exists to
avoid.

OnDemandRotationStartDate is blocked

It reports an in-progress RotateKeyOnDemand, which is absent from HandleRequest's switch and answers
unknownActionError. The member is unreachable until that operation exists, so it should be recorded as
deliberately absent — the honest-empty behaviour #827 established — and not emitted as a zero timestamp.
API_EnableKeyRotation notes on-demand rotation is available "regardless of whether or not automatic key
rotation is enabled"
, so it is genuinely independent of this issue rather than a variant of it.

The pending-deletion behaviour, which is a transition rather than a member

API_GetKeyRotationStatus, verbatim:

Disabled: The key rotation status does not change when you disable a KMS key.

Pending deletion: While a KMS key is pending deletion, its key rotation status is false and AWS
KMS does not rotate the key material. If you cancel the deletion, the original key rotation status
returns to true.

Substrate answers key.RotationEnabled in every state (kms_plugin.go:717-719), so:

  • a key pending deletion with rotation enabled reports true where AWS reports false;
  • and there is nowhere to restore from, because the reported value and the stored value are the same
    field. Modelling the restore needs the stored setting kept intact while the reported one reads false —
    that is, a state-derived answer rather than a stored one, which is the shape the Disabled line above
    confirms: disabling a key must not touch the stored setting.

The two lines together are a neat pair of assertions, and the Disabled half is already correct in
substrate — #949's tests pin that a refused rotation call leaves the setting alone. The pending-deletion
half is not.

This interacts with #963, which made CancelKeyDeletion leave the key Disabled: after a cancel the key
is disabled but not pending deletion, so per the two rules above the rotation status should read its
original true again while the key itself stays disabled. That is a three-step walk worth a test —
enable rotation, schedule deletion, observe false, cancel, observe true — and it is the kind of
sequence that cannot pass by accident.

Acceptance criteria

  • GetKeyRotationStatus reports NextRotationDate when rotation is enabled, computed from the enable
    date plus RotationPeriodInDays against the simulated clock, and omits it when rotation is disabled.
  • The enable date is stored when EnableKeyRotation succeeds, and is updated when a later
    EnableKeyRotation changes the period, since AWS documents the parameter as modifying an existing
    rotation period.
  • A key pending deletion reports KeyRotationEnabled: false without altering the stored setting, and
    the original value is reported again after CancelKeyDeletion — asserted as one wire sequence.
  • Disabling a key does not change the reported rotation status, per the page's Disabled line.
  • OnDemandRotationStartDate stays absent, recorded as blocked on RotateKeyOnDemand rather than
    emitted as a zero value.
  • Members are asserted against raw JSON, so an absent member is distinguished from a zero one.
  • No test depends on wall-clock time; the rotation date is asserted against the simulated clock.
  • docs/services.md records which of the five members are answered, and why the other is not.

Related

Activity

  1. added this to the v0.118.0 milestone on Sep 17, 2026
  2. added
    type: bug
    on Sep 17, 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

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions