@@ -6,6 +6,55 @@ Parameters:
66 Default : none
77
88Resources :
9+ PSUSecretsKMSKey :
10+ Type : AWS::KMS::Key
11+ Properties :
12+ EnableKeyRotation : true
13+ KeyPolicy :
14+ Version : 2012-10-17
15+ Id : PSUSecretsKeyPolicy
16+ Statement :
17+ - Sid : EnableIAMUserPermissions
18+ Effect : Allow
19+ Principal :
20+ AWS : !Sub "arn:aws:iam::${AWS::AccountId}:root"
21+ Action : kms:*
22+ Resource : " *"
23+ - Sid : Enable read only decrypt
24+ Effect : Allow
25+ Principal :
26+ AWS : " *"
27+ Action :
28+ - kms:DescribeKey
29+ - kms:Decrypt
30+ Resource : " *"
31+ Condition :
32+ ArnLike :
33+ aws:PrincipalArn : !Sub "arn:aws:iam::${AWS::AccountId}:role/aws-reserved/sso.amazonaws.com/${AWS::Region}/AWSReservedSSO_ReadOnly*"
34+
35+ PSUSecretsKMSKeyAlias :
36+ Type : AWS::KMS::Alias
37+ Properties :
38+ AliasName : !Sub alias/${StackName}-PSUSecretsKMSKey
39+ TargetKeyId : !Ref PSUSecretsKMSKey
40+
41+ UsePSUSecretsKMSKeyPolicy :
42+ Type : AWS::IAM::ManagedPolicy
43+ Properties :
44+ ManagedPolicyName : !Sub ${StackName}-UsePSUSecretsKMSKey
45+ PolicyDocument :
46+ Version : " 2012-10-17"
47+ Statement :
48+ - Sid : AllowKmsForSecretsEncryption
49+ Effect : Allow
50+ Action :
51+ - kms:DescribeKey
52+ - kms:GenerateDataKey*
53+ - kms:Encrypt
54+ - kms:ReEncrypt*
55+ - kms:Decrypt
56+ Resource : !GetAtt PSUSecretsKMSKey.Arn
57+
958 SQSSaltSecret :
1059 Type : AWS::SecretsManager::Secret
1160 Properties :
@@ -17,6 +66,34 @@ Resources:
1766 PasswordLength : 32
1867 ExcludePunctuation : true
1968
69+ PSUNotifyKIDSecret :
70+ Type : AWS::SecretsManager::Secret
71+ Properties :
72+ Name : !Sub ${StackName}-PSU-Notify-KID
73+ Description : The id of the key (KID) used to sign JWT to NHS Notify and sent in the header
74+ KmsKeyId : !Ref PSUSecretsKMSKey
75+
76+ PSUNotifyPrivateKeySecret :
77+ Type : AWS::SecretsManager::Secret
78+ Properties :
79+ Name : !Sub ${StackName}-PSU-Notify-PrivateKey
80+ Description : RSA private key (PEM) for signing JWT to NHS Notify
81+ KmsKeyId : !Ref PSUSecretsKMSKey
82+
83+ PSUNotifyApplicationIDSecret :
84+ Type : AWS::SecretsManager::Secret
85+ Properties :
86+ Name : !Sub ${StackName}-PSU-Notify-Application-ID
87+ Description : The application ID for the DoS application to use when sending notifications to NHS Notify (e.g. bd492cde-b67e-487b-97fd-44b7414c8e95)
88+ KmsKeyId : !Ref PSUSecretsKMSKey
89+
90+ PSUNotifyAPIKeySecret :
91+ Type : AWS::SecretsManager::Secret
92+ Properties :
93+ Name : !Sub ${StackName}-PSU-Notify-API-Key
94+ Description : API Key for NHS Notify
95+ KmsKeyId : !Ref PSUSecretsKMSKey
96+
2097 GetSQSSaltSecretPolicy :
2198 Type : AWS::IAM::ManagedPolicy
2299 Properties :
@@ -28,7 +105,25 @@ Resources:
28105 Action :
29106 - secretsmanager:GetSecretValue
30107 - secretsmanager:DescribeSecret
31- Resource : !Ref SQSSaltSecret
108+ Resource :
109+ - !Ref SQSSaltSecret
110+
111+ GetPSUSecretPolicy :
112+ Type : AWS::IAM::ManagedPolicy
113+ Properties :
114+ Description : " Allows reading PSU secret parameters"
115+ PolicyDocument :
116+ Version : 2012-10-17
117+ Statement :
118+ - Effect : Allow
119+ Action :
120+ - secretsmanager:GetSecretValue
121+ - secretsmanager:DescribeSecret
122+ Resource :
123+ - !Ref PSUNotifyKIDSecret
124+ - !Ref PSUNotifyPrivateKeySecret
125+ - !Ref PSUNotifyApplicationIDSecret
126+ - !Ref PSUNotifyAPIKeySecret
32127
33128Outputs :
34129 SQSSaltSecret :
@@ -37,8 +132,44 @@ Outputs:
37132 Export :
38133 Name : !Sub ${StackName}-SQSSaltSecret
39134
135+ PSUNotifyKIDSecret :
136+ Description : The name of the PSU Notify KID secret
137+ Value : !Ref PSUNotifyKIDSecret
138+ Export :
139+ Name : !Sub ${StackName}-PSU-Notify-KID
140+
141+ PSUNotifyPrivateKeySecret :
142+ Description : The name of the PSU Notify Private Key secret
143+ Value : !Ref PSUNotifyPrivateKeySecret
144+ Export :
145+ Name : !Sub ${StackName}-PSU-Notify-PrivateKey
146+
147+ PSUNotifyApplicationIDSecret :
148+ Description : The name of the PSU Notify Application ID secret
149+ Value : !Ref PSUNotifyApplicationIDSecret
150+ Export :
151+ Name : !Sub ${StackName}-PSU-Notify-Application-ID
152+
153+ PSUNotifyAPIKeySecret :
154+ Description : The name of the PSU Notify API Key secret
155+ Value : !Ref PSUNotifyAPIKeySecret
156+ Export :
157+ Name : !Sub ${StackName}-PSU-Notify-API-Key
158+
159+ GetPSUSecretPolicy :
160+ Description : ARN of policy granting permission to read secrets
161+ Value : !Ref GetPSUSecretPolicy
162+ Export :
163+ Name : !Sub ${StackName}-GetPSUSecretPolicy
164+
40165 GetSQSSaltSecretPolicy :
41166 Description : ARN of policy granting permission to read the SQS salt secret
42167 Value : !Ref GetSQSSaltSecretPolicy
43168 Export :
44169 Name : !Sub ${StackName}-GetSQSSaltSecretPolicy
170+
171+ UsePSUSecretsKMSKeyPolicyArn :
172+ Description : ARN of managed policy granting PSU secrets KMS usage
173+ Value : !Ref UsePSUSecretsKMSKeyPolicy
174+ Export :
175+ Name : !Sub ${StackName}-UsePSUSecretsKMSKeyPolicyArn
0 commit comments