Skip to content

Commit 328e1e0

Browse files
committed
Move permission definition
1 parent ddbe840 commit 328e1e0

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

SAMtemplates/functions/main.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ Resources:
6363
CodeUri: ../../packages
6464
Handler: updatePrescriptionStatus.handler
6565
Role: !GetAtt UpdatePrescriptionStatusResources.Outputs.LambdaRoleArn
66-
Policies:
67-
- Statement:
68-
Effect: Allow
69-
Action:
70-
- sqs:sendmessage
71-
Resource:
72-
- !Ref NHSNotifyPrescriptionsSQSQueueArn
7366
Environment:
7467
Variables:
7568
TABLE_NAME: !Ref PrescriptionStatusUpdatesTableName
@@ -108,6 +101,7 @@ Resources:
108101
- - Fn::ImportValue: !Sub ${StackName}:tables:${PrescriptionStatusUpdatesTableName}:TableWritePolicyArn
109102
- Fn::ImportValue: !Sub ${StackName}:tables:${PrescriptionStatusUpdatesTableName}:TableReadPolicyArn
110103
- Fn::ImportValue: !Sub ${StackName}:tables:UsePrescriptionStatusUpdatesKMSKeyPolicyArn
104+
- Fn::ImportValue: !Sub ${StackName}-WriteNHSNotifyPrescriptionsSQSQueuePolicyArn
111105
LogRetentionInDays: !Ref LogRetentionInDays
112106
CloudWatchKMSKeyId: !ImportValue account-resources:CloudwatchLogsKmsKeyArn
113107
EnableSplunk: !Ref EnableSplunk

SAMtemplates/messaging/main.yaml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,25 @@ Resources:
3636
Statement:
3737
- Effect: Allow
3838
Action:
39-
- sqs:ChangeMessageVisibility
40-
- sqs:DeleteMessage
4139
- sqs:ReceiveMessage
4240
- sqs:GetQueueAttributes
4341
- sqs:GetQueueUrl
4442
- sqs:ListQueues
4543
Resource: !GetAtt NHSNotifyPrescriptionsSQSQueue.Arn
46-
44+
45+
WriteNHSNotifyPrescriptionsSQSQueuePolicy:
46+
Type: AWS::IAM::ManagedPolicy
47+
Properties:
48+
ManagedPolicyName: !Sub ${AWS::StackName}-NHSNotifyPrescriptionsSendMessagePolicy
49+
PolicyDocument:
50+
Version: "2012-10-17"
51+
Statement:
52+
- Effect: Allow
53+
Action:
54+
- sqs:SendMessage
55+
- sqs:DeleteMessage
56+
Resource: !GetAtt NSNotifyPrescriptionsSQSQueue.Arn
57+
4758
Outputs:
4859
NHSNotifyPrescriptionsSQSQueueUrl:
4960
Description: The URL of the NHS Notify Prescriptions SQS Queue
@@ -56,3 +67,16 @@ Outputs:
5667
Value: !GetAtt NHSNotifyPrescriptionsSQSQueue.Arn
5768
Export:
5869
Name: !Sub ${AWS::StackName}-NHSNotifyPrescriptionsSQSQueueArn
70+
71+
ReadNHSNotifyPrescriptionsSQSQueuePolicyArn:
72+
Description: ARN of policy granting permission to read the prescriptions queue
73+
Value: !Ref ReadNHSNotifyPrescriptionsSQSQueuePolicy
74+
Export:
75+
Name: !Sub ${AWS::StackName}-ReadNHSNotifyPrescriptionsSQSQueuePolicyArn
76+
77+
78+
WriteNHSNotifyPrescriptionsSQSQueuePolicyArn:
79+
Description: ARN of policy granting permission to write to the prescriptions queue
80+
Value: !Ref WriteNHSNotifyPrescriptionsSQSQueuePolicy
81+
Export:
82+
Name: !Sub ${AWS::StackName}-WriteNHSNotifyPrescriptionsSQSQueuePolicyArn

0 commit comments

Comments
 (0)