Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

fix: Add SNS encryption for FhirWorksAlarm #462

Merged
merged 4 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cloudformation/alarms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ Resources:
Type: AWS::SNS::Topic
Properties:
DisplayName: !Join ['-', [FhirSolution, !Ref Stage, cloudwatch, alarm, topic]]
KmsMasterKeyId: !Ref SnsKMSKey
FhirWorksAlarmSNSTopicPolicy:
Type: AWS::SNS::TopicPolicy
DependsOn: FhirWorksAlarmSNSTopic
Expand Down
29 changes: 28 additions & 1 deletion cloudformation/kms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,31 @@ Resources:
Condition:
ArnLike:
kms:EncryptionContext:aws:logs:arn: !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:*

SnsAlias:
Type: AWS::KMS::Alias
Properties:
AliasName: !Join ['-', [alias/snsKey, !Ref Stage]]
TargetKeyId: !Ref SnsKMSKey
SnsKMSKey:
Type: AWS::KMS::Key
Properties:
EnableKeyRotation: true
Description: 'KMS CMK for SNS'
KeyPolicy:
Version: '2012-10-17'
Statement:
- Sid: 'Enable IAM Root Permissions'
Effect: Allow
Principal:
AWS: !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:root'
Action: 'kms:*'
Resource: '*'
- Sid: 'Allow Cloudwatch to use this Key Policy'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we had to have sns.amazonaws.com service principal w/kms:GenerateDataKey* and kms:Decrypt permissions in this policy as well. iirc, that was what allowed sns to encrypt and decrypt when sending to the subscribers.

Effect: Allow
Principal:
Service: cloudwatch.amazonaws.com
Action:
- kms:Encrypt
- kms:Decrypt
- kms:GenerateDataKey*
Resource: '*'