Skip to content

Commit 987f806

Browse files
authored
AWS KMS.1 compliant policy with dedicated kms key list (#1020)
* AWS KMS.1 compliant policy with dedicated kms key list Wildcard permissions on all kms keys is a security issue. Allowing access to only dedicated KMS keys keeps the setup secure. Keys using default encryption aws/secretsmanager are accessible by default. * refactor kms:Decrypt policy Input parameter KmsKeyList set default empty, gives permission on all resources. Override allow explicit list via input parameter
1 parent 8e5e22a commit 987f806

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

aws/logs_monitoring/template.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ Parameters:
289289
- "true"
290290
- "false"
291291
Description: Set to true to enable enhanced Lambda metrics. This will generate additional custom metrics for Lambda functions, including cold starts, estimated AWS costs, and custom tags. Default is false.
292+
KmsKeyList:
293+
Type: CommaDelimitedList
294+
Default: ""
295+
Description: List of KMS Key ARNs the Lambda forwarder function can use to decrypt, seperated by comma
292296
Conditions:
293297
IsAWSChina: !Equals [!Ref "AWS::Partition", aws-cn]
294298
IsGovCloud: !Equals [!Ref "AWS::Partition", aws-us-gov]
@@ -378,6 +382,8 @@ Conditions:
378382
- !Equals [!Join ["", !Ref VPCSubnetIds], ""]
379383
SetDdLogLevel: !Not
380384
- !Equals [!Ref DdLogLevel, ""]
385+
SetDdForwarderDecryptKeys: !Not
386+
- !Equals [!Join ["", !Ref KmsKeyList], ""]
381387
Rules:
382388
MustSetDdApiKey:
383389
Assertions:
@@ -656,7 +662,10 @@ Resources:
656662
# https://aws.amazon.com/premiumsupport/knowledge-center/s3-troubleshoot-403/#AWS_KMS_encryption
657663
- Action:
658664
- kms:Decrypt
659-
Resource: "*"
665+
Resource: !If
666+
- SetDdForwarderDecryptKeys
667+
- !Ref KmsKeyList
668+
- "*"
660669
Effect: Allow
661670
- !If
662671
- SetDDApiSsmParamName # Access the Datadog API key from Secrets Manager

0 commit comments

Comments
 (0)