Skip to content

Commit 089a311

Browse files
author
Brandon Dahler
committed
feat(keystore) Define Branch Key Store read consistency semantics
1 parent 03b76ef commit 089a311

File tree

2 files changed

+104
-1
lines changed

2 files changed

+104
-1
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
[//]: # "Copyright Amazon.com Inc. or its affiliates. All Rights Reserved."
2+
[//]: # "SPDX-License-Identifier: CC-BY-SA-4.0"
3+
4+
# Define Branch Key Store read consistency semantics
5+
6+
# Definitions
7+
8+
## Conventions used in this document
9+
10+
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
11+
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
12+
interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119).
13+
14+
# Background
15+
16+
The [branch key store](../../framework/branch-key-store.md) persists branch key versions
17+
in a persistent data store such as a DynamoDb table.
18+
19+
These distributed data stores often offer configurable read consistency,
20+
allowing customers to choose eventually consistent reads
21+
for optimal cost and performance
22+
if stale results are acceptable for their use-case.
23+
24+
The current specification does not specify when agents should expect
25+
the results of the read operations to reflect the updated state caused by mutation operations.
26+
27+
The current implementation utilizes eventually consistent reads in all current usage.
28+
29+
Consequently, a read operation will not necessarily reflect the latest results a mutation operation
30+
even if performed by the same agent in a serialized manner.
31+
32+
This change adds the option to require consistent reads and
33+
clarifies the required consistent read behavior for read operations.
34+
35+
## Detailed Explanation
36+
37+
The Branch Key Store's `GetActiveBranchKey`, `GetBranchKeyVersion`, and `GetBeaconKey` operations
38+
utilize AWS DDB `GetItem` calls which
39+
do not set the `ConsistentRead` flag.
40+
41+
When the `ConsistentRead` flag is unset or `false`,
42+
DynamoDb only provides eventually consistent read guarantees.
43+
44+
This eventually consistent behavior is intentional
45+
in order to optimize performance and cost.
46+
47+
However,
48+
customers may have non-standard situations
49+
which explicitly require consistent reads to be performed.
50+
51+
While key management operations SHOULD occur in control plane operations,
52+
those same control plane operations MAY need to perform encryption operations.
53+
54+
Usage of consistent reads ensures that encryption operations
55+
immediately following the `CreateKey` operation
56+
will be able to find the created keys.
57+
58+
Similarly,
59+
key rotation and re-encryption operations
60+
performed due to key compromise
61+
MUST use consistent reads to ensure that
62+
the encryption operations utilize the new branch key version.
63+
64+
# Changes
65+
66+
The change is to introduce a new, optional `Require Consistent Reads` option
67+
to the Branch Key Store specification.
68+
69+
This updates:
70+
71+
- The [Branch Key Store's Initialization](../../framework/branch-key-store.md#initialization)
72+
- The [Branch Key Store's GetActiveBranchKey operation](../../framework/branch-key-store.md#getactivebranchkey)
73+
- The [Branch Key Store's GetBranchKeyVersion operation](../../framework/branch-key-store.md#getbranchkeyversion)
74+
- The [Branch Key Store's GetBeaconKey operation](../../framework/branch-key-store.md#getbeaconkey)
75+
76+
This update clarifies the existing behavior in a backwards-compatible manner
77+
while allowing agents to opt-in to consistent reads when needed.

framework/branch-key-store.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55

66
## Version
77

8-
0.9.0
8+
0.10.0
99

1010
### Changelog
1111

12+
- 0.10.0
13+
- [Define Branch Key Store read consistency semantics](../changes/2025-07-24_define-branch-key-store-read-consistency-semantics/background.md)
1214
- 0.9.0
1315
- Re-add [Mitigate Version Race Condition in the Branch Key Store](../changes/2025-01-16_key-store-mitigate-update-race/background.md) with DynamoDB as the only branch key storage option
1416
- 0.8.0
@@ -76,6 +78,7 @@ The following inputs MAY be specified to create a KeyStore:
7678
- [ID](#keystore-id)
7779
- [AWS KMS Grant Tokens](#aws-kms-grant-tokens)
7880
- [DynamoDb Client](#dynamodb-client)
81+
- [Require Consistent Reads](#require-consistent-reads)
7982
- [KMS Client](#kms-client)
8083

8184
The following inputs MUST be specified to create a KeyStore:
@@ -112,6 +115,20 @@ and no DynamoDb Client is provided,
112115
a new DynamoDb Client MUST be created
113116
with the region configured in the MRDiscovery.
114117

118+
### Require Consistent Reads
119+
120+
Whether read operations are required to perform consistent reads,
121+
ensuring that recent write operations are reflected in their response.
122+
123+
If set to `true`,
124+
read operations MUST return results
125+
which reflect the result of
126+
the most recently executed write operations.
127+
128+
If unset or set to `false`,
129+
read operations MAY return stale results
130+
which are caused by eventual consistency.
131+
115132
### KMS Client
116133

117134
The KMS Client used when wrapping and unwrapping keys.
@@ -527,6 +544,9 @@ To get the active version for the branch key id from the keystore
527544
this operation MUST call AWS DDB `GetItem`
528545
using the `branch-key-id` as the Partition Key and `"branch:ACTIVE"` value as the Sort Key.
529546

547+
The [Require Consistent Reads](#require-consistent-reads) configured MUST be honored
548+
by setting `ConsistentReads` to `true` when consistent reads are needed.
549+
530550
The AWS DDB response MUST contain the fields defined in the [branch keystore record format](#record-format).
531551
If the record does not contain the defined fields, this operation MUST fail.
532552

@@ -549,6 +569,9 @@ On invocation, the caller:
549569
To get a branch key from the keystore this operation MUST call AWS DDB `GetItem`
550570
using the `branch-key-id` as the Partition Key and "branch:version:" + `branchKeyVersion` value as the Sort Key.
551571

572+
The [Require Consistent Reads](#require-consistent-reads) configured MUST be honored
573+
by setting `ConsistentReads` to `true` when consistent reads are needed.
574+
552575
The AWS DDB response MUST contain the fields defined in the [branch keystore record format](#record-format).
553576
If the record does not contain the defined fields, this operation MUST fail.
554577

@@ -570,6 +593,9 @@ On invocation, the caller:
570593
To get a branch key from the keystore this operation MUST call AWS DDB `GetItem`
571594
using the `branch-key-id` as the Partition Key and "beacon:ACTIVE" value as the Sort Key.
572595

596+
The [Require Consistent Reads](#require-consistent-reads) configured MUST be honored
597+
by setting `ConsistentReads` to `true` when consistent reads are needed.
598+
573599
The AWS DDB response MUST contain the fields defined in the [branch keystore record format](#record-format).
574600
If the record does not contain the defined fields, this operation MUST fail.
575601

0 commit comments

Comments
 (0)