Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow CloudFront logging to access KMS key #739

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions security/kms-key.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Parameters:
- workspaces
- dnssec-route53 # Deprecated since v13. Will be removed in v15. Use ROUTE53_DNSSEC instead.
- cloudtrail
- cloudfront-logs
Default: ALL_SERVICES
KeySpec:
Description: 'Specify the type of the CMK.'
Expand Down Expand Up @@ -89,6 +90,7 @@ Conditions:
HasServiceS3PublicAccess: !Equals [!Ref Service, 'S3_PUBLIC_ACCESS']
HasServiceRoute53Dnssec: !Or [!Equals [!Ref Service, 'ROUTE53_DNSSEC'], !Equals [!Ref Service, 'dnssec-route53']]
HasServiceCloudFront: !Equals [!Ref Service, 'CLOUDFRONT']
HasServiceCloudFrontLogs: !Equals [!Ref Service, 'cloudfront-logs']
HasServiceCloudTrail: !Equals [!Ref Service, 'CLOUDTRAIL']
HasService: !Not [!Or [!Condition HasServiceAllServices, !Condition HasServiceS3PublicAccess, !Condition HasServiceRoute53Dnssec, !Condition HasServiceCloudFront, !Condition HasServiceCloudTrail]]
HasSymmetricKey: !Equals [!Ref KeySpec, 'SYMMETRIC_DEFAULT']
Expand Down Expand Up @@ -205,6 +207,16 @@ Resources:
StringLike:
'aws:SourceArn': !Sub 'arn:aws:cloudfront::${AWS::AccountId}:distribution/*'
- !Ref 'AWS::NoValue'
- !If
- HasServiceCloudFrontLogs
- Effect: Allow # https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AccessLogs.html#AccessLogsKMSPermissions
Principal:
Service: 'delivery.logs.amazonaws.com'
Action:
- 'kms:GenerateDataKey*'
- 'kms:Decrypt'
Resource: '*'
- !Ref 'AWS::NoValue'
KeyAlias:
DeletionPolicy: Retain
UpdateReplacePolicy: Retain
Expand Down