Skip to content

Commit 873849f

Browse files
authored
Chore: [AEA-0000] - Set permissions for bare environment and make audit data extract conditional (#2265)
## Summary - Routine Change ### Details - allow deployment from new environments - make adding data extract to audit bucket conditional
1 parent f954480 commit 873849f

6 files changed

Lines changed: 39 additions & 20 deletions

File tree

cloudformation/account_resources.yml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ Parameters:
2929
3288,
3030
3653,
3131
]
32+
AddDataExtractToAuditBucket:
33+
Type: String
34+
Description: Whether to add the data extract bucket as a source to the audit logging bucket policy
35+
AllowedValues:
36+
- "true"
37+
- "false"
38+
39+
Conditions:
40+
AddDataExtractToAuditBucketCondition: !Equals [!Ref AddDataExtractToAuditBucket, "true"]
3241

3342
Resources:
3443
#region API Gateway
@@ -624,21 +633,24 @@ Resources:
624633
aws:SourceAccount: !Ref "AWS::AccountId"
625634
ArnLike:
626635
aws:SourceArn: !ImportValue "epsam:kbDocsBucket:Arn"
627-
- Effect: Allow
628-
Principal:
629-
Service: logging.s3.amazonaws.com
630-
Action:
631-
- s3:PutObject*
632-
Resource:
633-
- !Join [
634-
"",
635-
[!GetAtt AuditLoggingBucket.Arn, "/data-extract/*"],
636-
]
637-
Condition:
638-
StringEquals:
639-
aws:SourceAccount: !Ref "AWS::AccountId"
640-
ArnLike:
641-
aws:SourceArn: !ImportValue "data-extract:DestinationBucket:Arn"
636+
- !If
637+
- AddDataExtractToAuditBucketCondition
638+
- Effect: Allow
639+
Principal:
640+
Service: logging.s3.amazonaws.com
641+
Action:
642+
- s3:PutObject*
643+
Resource:
644+
- !Join [
645+
"",
646+
[!GetAtt AuditLoggingBucket.Arn, "/data-extract/*"],
647+
]
648+
Condition:
649+
StringEquals:
650+
aws:SourceAccount: !Ref "AWS::AccountId"
651+
ArnLike:
652+
aws:SourceArn: !ImportValue "data-extract:DestinationBucket:Arn"
653+
- !Ref AWS::NoValue
642654

643655
#endregion
644656

environmentSettings/dev.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@
114114
]
115115
},
116116
"account-resources": {
117-
"LogRetentionDays": "90"
117+
"LogRetentionDays": "90",
118+
"AddDataExtractToAuditBucket": "true"
118119
},
119120
"lambda-resources": {
120121
"SplunkHECEndpoint": "https://firehose.inputs.splunk.aws.digital.nhs.uk/services/collector/event",

environmentSettings/int.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"repo:NHSDigital/electronic-prescription-service-account-resources:environment:int-account",
88
"repo:NHSDigital/electronic-prescription-service-account-resources:environment:int-ci",
99
"repo:NHSDigital/electronic-prescription-service-account-resources:environment:int-lambda",
10+
"repo:NHSDigital/electronic-prescription-service-account-resources:environment:int",
1011
"repo:NHSDigital/electronic-prescription-service-clinical-prescription-tracker:environment:int",
1112
"repo:NHSDigital/eps-FHIR-validator-lambda:environment:int",
1213
"repo:NHSDigital/eps-prescription-status-update-api:environment:int",
@@ -73,7 +74,8 @@
7374
]
7475
},
7576
"account-resources": {
76-
"LogRetentionDays": "90"
77+
"LogRetentionDays": "90",
78+
"AddDataExtractToAuditBucket": "false"
7779
},
7880
"lambda-resources": {
7981
"SplunkHECEndpoint": "https://firehose.inputs.splunk.aws.digital.nhs.uk/services/collector/event",

environmentSettings/prod.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"repo:NHSDigital/electronic-prescription-service-account-resources:environment:prod-account",
88
"repo:NHSDigital/electronic-prescription-service-account-resources:environment:prod-ci",
99
"repo:NHSDigital/electronic-prescription-service-account-resources:environment:prod-lambda",
10+
"repo:NHSDigital/electronic-prescription-service-account-resources:environment:prod",
1011
"repo:NHSDigital/electronic-prescription-service-clinical-prescription-tracker:environment:prod",
1112
"repo:NHSDigital/eps-FHIR-validator-lambda:environment:prod",
1213
"repo:NHSDigital/eps-prescription-status-update-api:environment:prod",
@@ -83,7 +84,8 @@
8384
]
8485
},
8586
"account-resources": {
86-
"LogRetentionDays": "90"
87+
"LogRetentionDays": "90",
88+
"AddDataExtractToAuditBucket": "false"
8789
},
8890
"lambda-resources": {
8991
"SplunkHECEndpoint": "https://firehose.inputs.splunk.aws.digital.nhs.uk/services/collector/event",

environmentSettings/qa.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
]
7373
},
7474
"account-resources": {
75-
"LogRetentionDays": "90"
75+
"LogRetentionDays": "90",
76+
"AddDataExtractToAuditBucket": "true"
7677
},
7778
"lambda-resources": {
7879
"SplunkHECEndpoint": "https://firehose.inputs.splunk.aws.digital.nhs.uk/services/collector/event",

environmentSettings/ref.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
]
7676
},
7777
"account-resources": {
78-
"LogRetentionDays": "90"
78+
"LogRetentionDays": "90",
79+
"AddDataExtractToAuditBucket": "false"
7980
},
8081
"lambda-resources": {
8182
"SplunkHECEndpoint": "https://firehose.inputs.splunk.aws.digital.nhs.uk/services/collector/event",

0 commit comments

Comments
 (0)