You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,8 @@ It will create a Tracker and a Lambda function to stream data to the tracker, al
20
20
21
21
`EventBridgeEnabled`: Whether EventBridge integration is turned on. It may incur additional costs by leaving it on unused.
22
22
23
+
`KinesisStreamKmsKeyArn`: Optional. The ARN of the customer-managed KMS key (CMK) used for server-side encryption of your source Kinesis data stream. See [Encrypted Kinesis streams](#encrypted-kinesis-streams-customer-managed-kms-keys) below. Leave blank if your stream is unencrypted or uses the AWS-managed key (`aws/kinesis`).
24
+
23
25
Note that this app requires a [Kinesis Data Stream](https://docs.aws.amazon.com/streams/latest/dev/getting-started.html) as an input.
24
26
25
27
The app supports custom event structure via [JSONPath-ng](https://pypi.org/project/jsonpath-ng/).
@@ -57,6 +59,23 @@ List of paths that are configurable:
57
59
*`PathToHorizontalAccuracy` maps to the `Accuracy` parameter, specifically the `Horizontal` key. Default is `$.HorizontalAccuracy`. `Horizontal` is the only type of accuracy supported by the API.
58
60
*`PathToPositionProperties` maps to the `PositionProperties` parameter of the API.
If your source Kinesis data stream uses [server-side encryption](https://docs.aws.amazon.com/streams/latest/dev/server-side-encryption.html) with a **customer-managed KMS key (CMK)**, the function's execution role needs `kms:Decrypt` on that key so the event source can read records.
65
+
66
+
1. Set the `KinesisStreamKmsKeyArn` parameter to the CMK ARN (the underlying key ARN of the form `arn:aws:kms:<region>:<account>:key/<key-id>` — **not** an alias ARN, and the per-region key ARN actually used by the stream). The function is then granted only `kms:Decrypt`, scoped to that single key, and only for requests carrying the stream's encryption context (`kms:EncryptionContext:aws:kinesis:arn` equal to `KinesisStreamArn`).
67
+
2. The CMK's own [key policy](https://docs.aws.amazon.com/kms/latest/developerguide/key-policies.html) must also allow `kms:Decrypt` for this function's execution role principal — granting it in this template's IAM policy is necessary but not sufficient. Kinesis passes the encryption context `aws:kinesis:arn` (the stream ARN) on every KMS call it makes on the consumer's behalf.
68
+
69
+
If your stream is unencrypted or uses the AWS-managed key (`aws/kinesis`), leave `KinesisStreamKmsKeyArn` blank. No KMS permissions are granted in that case.
70
+
71
+
`kms:GenerateDataKey` is intentionally **not** granted (and is explicitly denied): this app only consumes (reads) records, and `GenerateDataKey` is a producer-side permission. To check whether your stream uses a CMK, run `aws kinesis describe-stream-summary --stream-name <name>` and look at `EncryptionType` (`KMS`) and `KeyId`.
72
+
73
+
## Upgrade notes
74
+
75
+
**Upgrading from a version before 1.1.0:** Earlier versions granted the function broad KMS permissions (`kms:Decrypt` and `kms:GenerateDataKey`) on every key in the account/region. Starting in 1.1.0 these are scoped to least privilege: `kms:GenerateDataKey` is removed entirely (and denied), and `kms:Decrypt` is granted only when you provide `KinesisStreamKmsKeyArn`, scoped to that one key and to requests carrying the stream's encryption context.
76
+
77
+
> ⚠️ **If your source stream is encrypted with a customer-managed KMS key, you must set `KinesisStreamKmsKeyArn` when you upgrade**, or the function will silently stop processing records (it will no longer be able to decrypt them). On update via the Serverless Application Repository console, make sure the new parameter is populated rather than left at its empty default. Deployments using an unencrypted stream or the AWS-managed `aws/kinesis` key are unaffected.
78
+
60
79
## Deploying for Private Development
61
80
62
81
To publish your own adaptions to the Serverless Application Repository as a private application, run the following:
@@ -121,6 +140,8 @@ This app logs failed executions or invalid position updates into its log group,
121
140
Note that this app calls BatchUpdateDevicePosition API. Retries on that API may result in the same position update being processed multiple times.
122
141
Amazon Location handles this case by only storing the most recent position update.
123
142
143
+
If `IteratorAge` climbs while there are **no** entries in the Lambda's log group, the most likely cause is a customer-managed-KMS-encrypted stream without decrypt access: confirm `KinesisStreamKmsKeyArn` is set to the stream's CMK ARN (see [Encrypted Kinesis streams](#encrypted-kinesis-streams-customer-managed-kms-keys)) and that the CMK key policy allows this role's `kms:Decrypt`.
144
+
124
145
## Security
125
146
126
147
See [CONTRIBUTING](./CONTRIBUTING.md#security-issue-notifications) for more information.
ConstraintDescription: Must be empty, or a KMS key ARN of the form arn:<partition>:kms:<region>:<account>:key/<key-id> (an alias ARN is not accepted).
44
+
Description: >-
45
+
REQUIRED IF your source Kinesis stream is encrypted with a customer-managed
46
+
KMS key (CMK): set this to that key's ARN or the function will stop processing
47
+
records. The function is then granted only kms:Decrypt, scoped to this one key
48
+
and to requests carrying the stream's encryption context. Leave blank if the
49
+
stream is unencrypted or uses the AWS-managed key (aws/kinesis); in that case
50
+
no KMS permissions are granted. Provide the key ARN (arn:...:key/<id>), not an
51
+
alias ARN.
39
52
PathToDeviceId:
40
53
Type: String
41
54
Default: '$.DeviceId'
@@ -60,6 +73,8 @@ Parameters:
60
73
Type: String
61
74
Default: '$.Properties'
62
75
Description: JSONPath to PositionProperties, for example $.Properties. Optional. See BatchUpdateDevicePosition documentation for the definition of PositionProperties.
0 commit comments