Repository navigation
Description
EnableKeyRotation decodes only KeyId, so RotationPeriodInDays is accepted, discarded and unreportable.
Found while implementing #949, which fixes the same handler's missing key-state check. This is the other half of what the operation publishes and is a separate defect: #949 is about a refusal that never happened, this is about a parameter that is never read.
What AWS publishes
API_EnableKeyRotation takes two parameters:
KeyId— String, 1–2048, Required: Yes.RotationPeriodInDays— Integer, Valid Range: Minimum value of 90. Maximum value of 2560, Required: No. "Specifies a custom period of time between each rotation date. If no value is specified, the default value is 365 days."
What substrate does
enableKeyRotation (kms_plugin.go) decodes exactly one member:
var input struct {
KeyID string `json:"KeyId"`
}So a caller specifying a 90-day rotation gets 200 and nothing recorded, and there is nowhere to read it back from: KMSKey (kms_types.go) has RotationEnabled bool and no period field, and GetKeyRotationStatus answers only KeyRotationEnabled.
That last point is worth checking before implementing rather than assuming — API_GetKeyRotationStatus publishes more response elements than substrate answers, and whether the period is among them decides whether recording it is observable at all. If it is not reportable through any operation substrate models, the honest fix may be to refuse an out-of-range value and record the rest as unobservable, rather than to store a value nothing can read — the reasoning #827 established for honest-empty behaviour, applied to a write.
Related and separate: ListKeyRotations and RotateKeyOnDemand are not implemented at all (they are absent from HandleRequest's switch, so they answer unknownActionError). Both appear in the key-state table with the same rows as EnableKeyRotation. They are not part of this issue.
Acceptance criteria
- Determine from
API_GetKeyRotationStatusandAPI_ListKeyRotationswhich response members carry the rotation period, and record the finding — it decides whether the value is observable. -
RotationPeriodInDaysoutside 90–2560 is refused;90and2560are both accepted, so the refusal cannot be off by one. AWS publishes no code for the range violation on this page, so the code is substrate's reading and is stated as such. - An absent
RotationPeriodInDaysbehaves as 365, per "if no value is specified, the default value is 365 days". - The value is either reportable through an operation substrate models, or recorded as accepted-and-unobservable with the reason — not stored where nothing can read it.
- Tests assert the status and the code, per fix(kms): NotFoundException is HTTP 400, and InvalidRequest is not a KMS code #923, and go over the wire, per cfn: the aws:cloudformation:* stamp covers EC2 only, so the rest of a stack is unstamped #765.
-
docs/services.md's KMS section records the parameter and whatever the observability finding turns out to be.
Activity
scttfrdmn commentedon Sep 17, 2026
AC 1 is answered, and it resolves the fork in favour of storing the value
The issue's first criterion asked whether
RotationPeriodInDaysis observable through any operationsubstrate models, because "if it is not reportable through any operation substrate models, the honest
fix may be to refuse an out-of-range value and record the rest as unobservable". It is reportable.
API_GetKeyRotationStatuspublishes it as a response element, verbatim:The range matches
EnableKeyRotation's request parameter exactly, and the page's own sample responsecarries it:
{ "KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab", "KeyRotationEnabled": true, "NextRotationDate": "2024-02-14T18:14:33.587000+00:00", "RotationPeriodInDays": 365 }So the value a caller writes through
EnableKeyRotationis readable back through an operation substratealready implements. The honest-empty branch does not apply, and the fix is the full one: decode the
member, range-check it, store it, and report it. AC 4 is satisfied by reporting it from
GetKeyRotationStatusrather than by recording it as unobservable.API_EnableKeyRotationalso settles a second thing the issue did not ask, and it is the reason themember is worth storing rather than merely validating — the parameter is not write-once:
A second
EnableKeyRotationwith a different period therefore changes the stored value, which is anassertable behaviour and will get its own test.
AC 2: the code for a range violation is
ValidationError/400, following the in-tree precedentAC 2 anticipated correctly that AWS publishes no code for the range violation on the operation page.
API_EnableKeyRotation's seven errors areDependencyTimeoutException/500,DisabledException/400,InvalidArnException/400,KMSInternalException/500,KMSInvalidStateException/400,NotFoundException/400 andUnsupportedOperationException/400 — none of which is a range violation.UnsupportedOperationExceptionis the near miss and is deliberately not chosen: its gloss is "aspecified parameter is not supported or a specified resource is not valid for this operation", which is
about a parameter or resource being inadmissible, not about an admissible parameter carrying an
out-of-range value. It is the code for the symmetric-only restriction instead (filed separately, below).
The code is
ValidationError/400 fromCommonErrors.html, with a message naming both the value and therange — which is not a fresh decision but the existing one in this exact file.
kmsInvalidPendingWindow(
kms_errors.go:159-167) already does precisely this forScheduleKeyDeletion's 7–30 window: sameshape of defect, same protocol layer, same code. Two range violations in one plugin answering two
different codes would be the divergence #923 exists to prevent, so this one follows it.
90and2560will both be accepted, per AC 2, so the bound cannot be off by one.A defect this turned up, which is the mirror image of #964
While confirming where rotation state is observable, the opposite error turned out to be present:
substrate reports rotation state where AWS does not publish it.
DescribeKey'sKeyMetadata(kms_plugin.go:389) renders a memberRotationEnabled:API_KeyMetadatahas no such member. Its Contents section lists 26 —KeyId,Arn,AWSAccountId,CloudHsmClusterId,CreationDate,CurrentKeyMaterialId,CustomerMasterKeySpec,CustomKeyStoreId,DeletionDate,Description,Enabled,EncryptionAlgorithms,ExpirationModel,KeyAgreementAlgorithms,KeyManager,KeySpec,KeyState,KeyUsage,MacAlgorithms,MultiRegion,MultiRegionConfiguration,Origin,PendingDeletionWindowInDays,SigningAlgorithms,ValidTo,XksKeyConfiguration— andRotationEnabledis not among them. The string does not appear on the page at all. Rotation state isreachable through
GetKeyRotationStatusandListKeyRotationsonly, which is exactly whyAPI_EnableKeyRotationtells a caller "You can use the GetKeyRotationStatus operation to identify anyin progress rotations" rather than pointing at
DescribeKey.So substrate publishes rotation state on the one shape AWS omits it from, and omits the period from the
one operation AWS publishes it on. That is one defect seen from two ends, and a consumer can be misled
in a way worth spelling out: a caller who reads
DescribeKey().KeyMetadata.RotationEnabledagainstsubstrate gets an answer, and against real AWS gets an absent field — a green test for code that cannot
work. That is the #765 failure mode applied to a response member.
Filed as its own issue rather than folded in silently, and the #964 PR will close both, because
answering where rotation state is observable is the whole content of AC 1 and correcting the wrong
place is the same change. No test asserts the member today — a repo-wide grep finds the KMS assertions
all reading
KeyRotationEnabledfromGetKeyRotationStatus, which is correct — so removing it breaksnothing in tree. It is still a wire change and will be called out under Compatibility.
Three further findings, filed separately, not in this issue's scope
1.
EnableKeyRotationandDisableKeyRotationaccept a key type AWS refuses. Verbatim:UnsupportedOperationException/400 is published on both pages and is the code for it. Substrate readsneither
KeySpecnorKeyUsagein either handler, soEnableKeyRotationon anRSA_4096orHMAC_256key answers 200 and records rotation on a key that cannot rotate. This is a missing refusalof the same class as #968, not a discarded parameter, so it is its own issue.
2.
GetKeyRotationStatusomits two more published members, and its pending-deletion behaviour isunmodelled. The response has five elements and substrate answers one.
RotationPeriodInDaysandKeyIdcome with this issue — a period reported without saying which key it belongs to is not acoherent body.
NextRotationDateandOnDemandRotationStartDatedo not: the first is derivable fromthe enable date plus the period against the simulated clock, the second requires
RotateKeyOnDemand,which is not implemented. The same page also documents behaviour substrate does not have:
Substrate answers the stored
RotationEnabledin every state, so a key pending deletion reportstruewhere AWS reports
false, and the restore-on-cancel behaviour has nowhere to restore from. That is astate transition rather than a member, and it interacts with #963's deletion pair, so it is filed with
the two members.
3.
kms:RotationPeriodInDaysis a published condition key — "You can use thekms:RotationPeriodInDayscondition key to further constrain the values that principals can specify inthe
RotationPeriodInDaysparameter." Substrate's condition-key handling for KMS does not model it.Noted for the authorization work rather than filed against rotation; it only becomes meaningful once
the parameter is decoded, which is what this issue does.
Two corrections to this issue's own body
Both minor, recorded because the issue will be read alongside the PR:
RotationPeriodInDaysquotation is accurate but partial. The full parameter entry adds themodify-an-existing-period sentence quoted above and the condition-key sentence, and the second
paragraph — "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" — is what makes
NextRotationDatederivable rather than arbitrary.ListKeyRotationsandRotateKeyOnDemandare not implemented at all" is confirmed against theswitch, and
API_EnableKeyRotation's Related operations section lists both plusGetKeyRotationStatus, so the four form one cluster. Correctly excluded from this issue; theOnDemandRotationStartDatemember above is blocked onRotateKeyOnDemandand is recorded that way.Nothing here changes AC 3, 5 or 6. AC 1 is answered, AC 2's code is chosen with its precedent, and AC 4
resolves to reportable rather than to accepted-and-unobservable.
fix(kms): store EnableKeyRotation's period, and stop DescribeKey inve…
fix(kms): rotation checks the key type, and reports when the next one…