Repository navigation
Description
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
}KeyId— String, 1–2048. Delivered by kms: EnableKeyRotation decodes only KeyId, so RotationPeriodInDays is accepted and discarded #964.KeyRotationEnabled— Boolean. Already answered.RotationPeriodInDays— Integer, 90–2560, default 365. Delivered by kms: EnableKeyRotation decodes only KeyId, so RotationPeriodInDays is accepted and discarded #964.NextRotationDate— "The next date that AWS KMS will automatically rotate the key material."
Timestamp. Not delivered by kms: EnableKeyRotation decodes only KeyId, so RotationPeriodInDays is accepted and discarded #964.OnDemandRotationStartDate— "Identifies the date and time that an in progress on-demand rotation
was initiated." Timestamp, and "Once the on-demand rotation is complete, AWS KMS removes this field
from the response." Not delivered by kms: EnableKeyRotation decodes only KeyId, so RotationPeriodInDays is accepted and discarded #964.
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
falseand AWS
KMS does not rotate the key material. If you cancel the deletion, the original key rotation status
returns totrue.
Substrate answers key.RotationEnabled in every state (kms_plugin.go:717-719), so:
- a key pending deletion with rotation enabled reports
truewhere AWS reportsfalse; - 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 readsfalse—
that is, a state-derived answer rather than a stored one, which is the shape theDisabledline 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
-
GetKeyRotationStatusreportsNextRotationDatewhen rotation is enabled, computed from the enable
date plusRotationPeriodInDaysagainst the simulated clock, and omits it when rotation is disabled. - The enable date is stored when
EnableKeyRotationsucceeds, and is updated when a later
EnableKeyRotationchanges the period, since AWS documents the parameter as modifying an existing
rotation period. - A key pending deletion reports
KeyRotationEnabled: falsewithout altering the stored setting, and
the original value is reported again afterCancelKeyDeletion— asserted as one wire sequence. - Disabling a key does not change the reported rotation status, per the page's
Disabledline. -
OnDemandRotationStartDatestays absent, recorded as blocked onRotateKeyOnDemandrather 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.mdrecords which of the five members are answered, and why the other is not.
Related
- kms: EnableKeyRotation decodes only KeyId, so RotationPeriodInDays is accepted and discarded #964 — delivers
KeyIdandRotationPeriodInDays, and is the prerequisite forNextRotationDate
because it stores the period this computes from. - kms: ScheduleKeyDeletion and CancelKeyDeletion check no key state, and CancelKeyDeletion leaves the key Enabled where AWS leaves it Disabled #963 — supplies the
CancelKeyDeletionsemantics the restore-on-cancel assertion depends on. ListKeyRotationsandRotateKeyOnDemandremain unimplemented and are the blockers for
OnDemandRotationStartDate.
Activity
fix(kms): rotation checks the key type, and reports when the next one…