Skip to content

Commit 8087634

Browse files
committed
adding each region specifically in perms
1 parent e9dadec commit 8087634

File tree

2 files changed

+41
-38
lines changed

2 files changed

+41
-38
lines changed

aws_sra_examples/solutions/guardduty/guardduty_org/templates/sra-guardduty-org-delivery-kms-key.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ Resources:
7373
# temp retain for troubleshooting
7474
DeletionPolicy: Retain
7575
# checkov:skip=CKV_AWS_33:Ensure KMS key policy does not contain wildcard (*) principal
76-
Metadata:
77-
cfn_nag:
78-
rules_to_suppress:
79-
- id: F76
80-
reason: "Opt-in regions may be used and so conditional policy is required"
76+
# Metadata:
77+
# cfn_nag:
78+
# rules_to_suppress:
79+
# - id: F76
80+
# reason: "Opt-in regions may be used and so conditional policy is required"
8181
Type: AWS::KMS::Key
8282
Properties:
8383
Description: SRA GuardDuty Delivery Key
@@ -101,14 +101,14 @@ Resources:
101101
Service: guardduty.amazonaws.com
102102

103103
# key permissions for potential opt-in regions (conditional)
104-
- Sid: Allow opt-in region GuardDuty to encrypt logs
104+
- Sid: Allow opt-in GuardDuty to encrypt logs
105105
Effect: Allow
106106
Action: kms:GenerateDataKey
107107
Resource: '*'
108-
Principal: '*'
109-
Condition:
110-
StringLike:
111-
aws:PrincipalServiceName: guardduty.*.amazonaws.com
108+
Principal:
109+
Service:
110+
- guardduty.ap-southeast-4.amazonaws.com
111+
- guardduty.ap-east-1.amazonaws.com
112112

113113
- Sid: Allow alias creation during setup
114114
Effect: Allow

aws_sra_examples/solutions/guardduty/guardduty_org/templates/sra-guardduty-org-delivery-s3-bucket.yaml

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ Resources:
9191
rGuardDutyDeliveryS3BucketPolicy:
9292
# temp retain for troubleshooting
9393
DeletionPolicy: Retain
94-
Metadata:
95-
cfn_nag:
96-
rules_to_suppress:
97-
- id: F16
98-
reason: "Opt-in regions may be used and so conditional policy is required"
94+
# Metadata:
95+
# cfn_nag:
96+
# rules_to_suppress:
97+
# - id: F16
98+
# reason: "Opt-in regions may be used and so conditional policy is required"
9999
Type: AWS::S3::BucketPolicy
100100
Properties:
101101
Bucket: !Ref rGuardDutyDeliveryS3Bucket
@@ -136,17 +136,17 @@ Resources:
136136
- guardduty.amazonaws.com
137137

138138
# Bucket perm/location check allow for potential opt-in regions
139-
- Sid: AWSBucketPermissionsCheck
139+
- Sid: AWSBucketPermissionsCheckOptinRegions
140140
Effect: Allow
141141
Action:
142142
- s3:GetBucketAcl
143143
- s3:GetBucketLocation
144144
- s3:ListBucket
145145
Resource: !Sub arn:aws:s3:::${rGuardDutyDeliveryS3Bucket}
146-
Principal: '*'
147-
Condition:
148-
StringLike:
149-
aws:PrincipalServiceName: guardduty.*.amazonaws.com
146+
Principal:
147+
Service:
148+
- guardduty.ap-southeast-4.amazonaws.com
149+
- guardduty.ap-east-1.amazonaws.com
150150

151151
- Sid: AWSBucketDelivery
152152
Effect: Allow
@@ -163,13 +163,14 @@ Resources:
163163
- Sid: AWSBucketDeliveryOptinRegions
164164
Effect: Allow
165165
Action: s3:PutObject
166+
# Condition:
167+
# StringEquals:
168+
# s3:x-amz-acl: bucket-owner-full-control
166169
Resource: !Sub arn:aws:s3:::${rGuardDutyDeliveryS3Bucket}/*
167-
Principal: '*'
168-
Condition:
169-
StringLike:
170-
aws:PrincipalServiceName: guardduty.*.amazonaws.com
171-
# StringEquals:
172-
# s3:x-amz-acl: bucket-owner-full-control
170+
Principal:
171+
Service:
172+
- guardduty.ap-southeast-4.amazonaws.com
173+
- guardduty.ap-east-1.amazonaws.com
173174

174175
- Sid: DenyUnencryptedObjectUploads
175176
Effect: Deny
@@ -186,13 +187,14 @@ Resources:
186187
- Sid: DenyUnencryptedObjectUploadsOptinRegions
187188
Effect: Deny
188189
Action: s3:PutObject
189-
Resource: !Sub arn:aws:s3:::${rGuardDutyDeliveryS3Bucket}/*
190-
Principal: '*'
191190
Condition:
192-
StringLike:
193-
aws:PrincipalServiceName: guardduty.*.amazonaws.com
194-
# StringNotEquals:
195-
# s3:x-amz-server-side-encryption: aws:kms
191+
StringNotEquals:
192+
s3:x-amz-server-side-encryption: aws:kms
193+
Resource: !Sub arn:aws:s3:::${rGuardDutyDeliveryS3Bucket}/*
194+
Principal:
195+
Service:
196+
- guardduty.ap-southeast-4.amazonaws.com
197+
- guardduty.ap-east-1.amazonaws.com
196198

197199
- Sid: DenyIncorrectEncryptionHeader
198200
Effect: Deny
@@ -209,13 +211,14 @@ Resources:
209211
- Sid: DenyIncorrectEncryptionHeaderOptinRegions
210212
Effect: Deny
211213
Action: s3:PutObject
212-
Resource: !Sub arn:aws:s3:::${rGuardDutyDeliveryS3Bucket}/*
213-
Principal: '*'
214214
Condition:
215-
StringLike:
216-
aws:PrincipalServiceName: guardduty.*.amazonaws.com
217-
# StringNotEquals:
218-
# s3:x-amz-server-side-encryption-aws-kms-key-id: !Sub ${pGuardDutyOrgDeliveryKMSKeyArn}
215+
StringNotEquals:
216+
s3:x-amz-server-side-encryption-aws-kms-key-id: !Sub ${pGuardDutyOrgDeliveryKMSKeyArn}
217+
Resource: !Sub arn:aws:s3:::${rGuardDutyDeliveryS3Bucket}/*
218+
Principal:
219+
Service:
220+
- guardduty.ap-southeast-4.amazonaws.com
221+
- guardduty.ap-east-1.amazonaws.com
219222

220223

221224
Outputs:

0 commit comments

Comments
 (0)