Skip to content

Commit b31b4cd

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

File tree

2 files changed

+108
-1
lines changed

2 files changed

+108
-1
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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
30+
of a mutation operation
31+
even if performed by the same agent in a serialized manner.
32+
33+
This change adds the option to require consistent reads and
34+
clarifies the required consistent read behavior for read operations.
35+
36+
## Detailed Explanation
37+
38+
The Branch Key Store's `GetActiveBranchKey`, `GetBranchKeyVersion`, and `GetBeaconKey` operations
39+
utilize AWS DDB `GetItem` calls which
40+
do not set the `ConsistentRead` flag.
41+
42+
When the `ConsistentRead` flag is unset or `false`,
43+
DynamoDb only provides eventually consistent read guarantees.
44+
45+
This eventually consistent behavior is intentional
46+
in order to optimize performance and cost.
47+
48+
However,
49+
customers may have non-standard situations
50+
which explicitly require consistent reads to be performed.
51+
52+
While key management operations SHOULD occur in control plane operations,
53+
those same control plane operations MAY need to perform encryption operations.
54+
55+
Usage of consistent reads ensures that encryption operations
56+
immediately following the `CreateKey` operation
57+
will be able to find the created keys.
58+
59+
Similarly,
60+
key rotation and re-encryption operations
61+
performed due to key compromise
62+
MUST use consistent reads to ensure that
63+
the encryption operations utilize the new branch key version.
64+
65+
# Changes
66+
67+
The change is to introduce a new, optional `Require Consistent Reads` option
68+
to the Branch Key Store specification.
69+
70+
This updates:
71+
72+
- The [Branch Key Store's Initialization](../../framework/branch-key-store.md#initialization)
73+
- The [Branch Key Store's GetActiveBranchKey operation](../../framework/branch-key-store.md#getactivebranchkey)
74+
- The [Branch Key Store's GetBranchKeyVersion operation](../../framework/branch-key-store.md#getbranchkeyversion)
75+
- The [Branch Key Store's GetBeaconKey operation](../../framework/branch-key-store.md#getbeaconkey)
76+
77+
This update clarifies the existing behavior in a backwards-compatible manner
78+
while allowing agents to opt-in to consistent reads when needed.

framework/branch-key-store.md

Lines changed: 30 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,10 @@ 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) configuration MUST be honored
548+
by setting `ConsistentRead` to `true`
549+
when consistent reads are required.
550+
530551
The AWS DDB response MUST contain the fields defined in the [branch keystore record format](#record-format).
531552
If the record does not contain the defined fields, this operation MUST fail.
532553

@@ -549,6 +570,10 @@ On invocation, the caller:
549570
To get a branch key from the keystore this operation MUST call AWS DDB `GetItem`
550571
using the `branch-key-id` as the Partition Key and "branch:version:" + `branchKeyVersion` value as the Sort Key.
551572

573+
The [Require Consistent Reads](#require-consistent-reads) configuration MUST be honored
574+
by setting `ConsistentRead` to `true`
575+
when consistent reads are required.
576+
552577
The AWS DDB response MUST contain the fields defined in the [branch keystore record format](#record-format).
553578
If the record does not contain the defined fields, this operation MUST fail.
554579

@@ -570,6 +595,10 @@ On invocation, the caller:
570595
To get a branch key from the keystore this operation MUST call AWS DDB `GetItem`
571596
using the `branch-key-id` as the Partition Key and "beacon:ACTIVE" value as the Sort Key.
572597

598+
The [Require Consistent Reads](#require-consistent-reads) configuration MUST be honored
599+
by setting `ConsistentRead` to `true`
600+
when consistent reads are required.
601+
573602
The AWS DDB response MUST contain the fields defined in the [branch keystore record format](#record-format).
574603
If the record does not contain the defined fields, this operation MUST fail.
575604

0 commit comments

Comments
 (0)