Skip to content

Commit a60a0fa

Browse files
make kms encryption key optional
1 parent 50910a1 commit a60a0fa

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

modules/log_ingestion.s3.cft.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,13 @@ Parameters:
7070
AllowedPattern: 'arn:(aws|aws-us-gov):s3:::.*'
7171
KMSKeyARN:
7272
Type: String
73-
Description: The ARN of the KMS key used to encrypt the S3 bucket.
73+
Description: (Optional) The ARN of the KMS key used to encrypt the S3 bucket.
7474
Default: ""
7575
KMSAccountId:
7676
Type: String
77-
Description: The AWS Account ID that owns the KMS key.
78-
AllowedPattern: '^[0-9]{12}$'
77+
Description: (Optional) The AWS Account ID that owns the KMS key.
78+
AllowedPattern: '(^$|^[0-9]{12}$)'
79+
Default: ""
7980
BucketAccountId:
8081
Type: String
8182
Description: The AWS Account ID that owns the S3 bucket, if different from the current account.
@@ -108,6 +109,14 @@ Parameters:
108109
Conditions:
109110
CreateSNSTopic: !Equals [ !Ref CreateTopic, "true" ]
110111
HasKMSKey: !Not [ !Equals [ !Ref KMSKeyARN, "" ] ]
112+
HasKMSAccountId: !Not [ !Equals [ !Ref KMSAccountId, "" ] ]
113+
114+
NeedKMSPolicy: !And [
115+
!Condition HasKMSKey,
116+
!Condition HasKMSAccountId,
117+
!Not [ !Equals [ !Ref KMSAccountId, !Ref BucketAccountId ] ]
118+
]
119+
111120
DeployStackSet: !Or [
112121
!Not [ !Equals [ !Ref BucketAccountId, !Ref "AWS::AccountId" ] ],
113122
!Not [ !Equals [ !Ref TopicAccountId, !Ref "AWS::AccountId" ] ]
@@ -118,10 +127,6 @@ Conditions:
118127
!Not [ !Condition DeployStackSet ]
119128
]
120129

121-
NeedKMSPolicy: !And [
122-
!Not [ !Equals [ !Ref KMSKeyARN, "" ] ],
123-
!Not [ !Equals [ !Ref KMSAccountId, !Ref BucketAccountId ] ]
124-
]
125130
IsTopicAccount: !Equals [ !Ref TopicAccountId, !Ref "AWS::AccountId" ]
126131

127132
Resources:

0 commit comments

Comments
 (0)