Skip to content

Commit 6812ee5

Browse files
full install SNS support
1 parent 670d825 commit 6812ee5

File tree

3 files changed

+142
-5
lines changed

3 files changed

+142
-5
lines changed

templates_cloudlogs/OrgCloudLogs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,4 @@ Outputs:
165165

166166
TopicARN:
167167
Description: "The ARN of the SNS Topic created for CloudTrail notifications."
168-
Value: !If [CreateSNSTopic, !Ref CloudTrailNotificationsTopic, !Ref TopicARN]
168+
Value: !If [CreateSNSTopic, !Ref CloudTrailNotificationsTopic, !Ref TopicARN]

templates_cspm_cloudlogs/FullInstall.yaml

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Metadata:
1212
- ExternalID
1313
- TrustedIdentity
1414
- BucketARN
15+
- CreateTopic
16+
- TopicARN
17+
- Endpoint
1518

1619
ParameterLabels:
1720
CSPMRoleName:
@@ -24,23 +27,51 @@ Metadata:
2427
default: "Trusted Identity (Sysdig use only)"
2528
BucketARN:
2629
default: "Bucket ARN"
30+
CreateTopic:
31+
default: "Create SNS Topic"
32+
TopicARN:
33+
default: "SNS Topic ARN"
34+
Endpoint:
35+
default: "Sysdig Secure endpoint"
2736

2837
Parameters:
2938
CSPMRoleName:
3039
Type: String
3140
Description: The read-only IAM Role that Sysdig will create
41+
3242
CloudLogsRoleName:
3343
Type: String
3444
Description: The name of the IAM Role that will enable access to the Cloudtrail logs.
45+
3546
ExternalID:
3647
Type: String
3748
Description: Sysdig ExternalID required for the policy creation
49+
3850
TrustedIdentity:
3951
Type: String
4052
Description: The name of Sysdig trusted identity.
53+
4154
BucketARN:
4255
Type: String
43-
Description: The ARN of your s3 bucket associated with your Cloudtrail trail.
56+
Description: The ARN of your S3 bucket associated with your CloudTrail trail.
57+
58+
CreateTopic:
59+
Type: String
60+
AllowedValues:
61+
- "true"
62+
- "false"
63+
Default: "false"
64+
Description: "Whether to create a new SNS Topic for CloudTrail notifications."
65+
66+
TopicARN:
67+
Type: String
68+
Default: ""
69+
Description: "The ARN of an existing SNS Topic. If CreateTopic is true, this will be used as the name of the new topic."
70+
71+
Endpoint:
72+
Type: String
73+
Default: ""
74+
Description: "Sysdig Secure endpoint to receive CloudTrail notifications."
4475

4576
Resources:
4677
CloudAgentlessRole:
@@ -101,6 +132,8 @@ Resources:
101132
Condition:
102133
StringEquals:
103134
"sts:ExternalId": !Ref ExternalID
135+
136+
# IAM Policy
104137
CloudLogsRolePolicies:
105138
Type: "AWS::IAM::Policy"
106139
Properties:
@@ -123,4 +156,45 @@ Resources:
123156
- !Sub '${BucketARN}'
124157
- !Sub '${BucketARN}/*'
125158
Roles:
126-
- Ref: "CloudLogsRole"
159+
- !Ref CloudLogsRole
160+
161+
CloudTrailNotificationsTopic:
162+
Condition: CreateSNSTopic
163+
Type: "AWS::SNS::Topic"
164+
Properties:
165+
TopicName: !Select [ 5, !Split [ ":", !Ref TopicARN ] ]
166+
167+
CloudTrailNotificationsSubscription:
168+
Type: "AWS::SNS::Subscription"
169+
Properties:
170+
TopicArn: !If [ CreateSNSTopic, !Ref CloudTrailNotificationsTopic, !Ref TopicARN ]
171+
Protocol: "https"
172+
Endpoint: !Ref Endpoint
173+
174+
CloudTrailNotificationsPolicy:
175+
Condition: CreateSNSTopic
176+
Type: "AWS::SNS::TopicPolicy"
177+
Properties:
178+
Topics:
179+
- !Ref CloudTrailNotificationsTopic
180+
PolicyDocument:
181+
Version: "2012-10-17"
182+
Statement:
183+
- Sid: "AllowCloudTrailPublish"
184+
Effect: "Allow"
185+
Principal:
186+
Service: "cloudtrail.amazonaws.com"
187+
Action: "SNS:Publish"
188+
Resource: !Ref CloudTrailNotificationsTopic
189+
190+
Conditions:
191+
CreateSNSTopic: !Equals [ !Ref CreateTopic, "true" ]
192+
193+
Outputs:
194+
RoleARN:
195+
Description: "The ARN of the IAM Role created for CloudTrail logs."
196+
Value: !GetAtt CloudLogsRole.Arn
197+
198+
TopicARN:
199+
Description: "The ARN of the SNS Topic created for CloudTrail notifications."
200+
Value: !If [ CreateSNSTopic, !Ref CloudTrailNotificationsTopic, !Ref TopicARN ]

templates_cspm_cloudlogs/OrgFullInstall.yaml

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Metadata:
1313
- TrustedIdentity
1414
- BucketARN
1515
- OrganizationUnitIDs
16+
- CreateTopic
17+
- TopicARN
18+
- Endpoint
1619

1720
ParameterLabels:
1821
CSPMRoleName:
@@ -27,6 +30,12 @@ Metadata:
2730
default: "Trusted Identity (Sysdig use only)"
2831
OrganizationUnitIDs:
2932
default: "Organization Unit IDs (Sysdig use only)"
33+
CreateTopic:
34+
default: "Create SNS Topic"
35+
TopicARN:
36+
default: "SNS Topic ARN"
37+
Endpoint:
38+
default: "Sysdig Secure endpoint"
3039

3140
Parameters:
3241
CSPMRoleName:
@@ -40,7 +49,22 @@ Parameters:
4049
Description: Sysdig ExternalID required for the policy creation
4150
BucketARN:
4251
Type: String
43-
Description: The ARN of your s3 bucket associated with your Cloudtrail trail.
52+
Description: The ARN of your S3 bucket associated with your CloudTrail trail.
53+
CreateTopic:
54+
Type: String
55+
AllowedValues:
56+
- "true"
57+
- "false"
58+
Default: "false"
59+
Description: "Whether to create a new SNS Topic for CloudTrail notifications."
60+
TopicARN:
61+
Type: String
62+
Default: ""
63+
Description: "The ARN of an existing SNS Topic. If CreateTopic is true, this will be used as the name of the new topic."
64+
Endpoint:
65+
Type: String
66+
Default: ""
67+
Description: "Sysdig Secure endpoint to receive CloudTrail notifications."
4468
TrustedIdentity:
4569
Type: String
4670
Description: The Role in Sysdig's AWS Account with permissions to your account
@@ -65,6 +89,34 @@ Resources:
6589
sts:ExternalId: !Sub ${ExternalID}
6690
ManagedPolicyArns:
6791
- arn:aws:iam::aws:policy/SecurityAudit
92+
CloudTrailNotificationsTopic:
93+
Condition: CreateSNSTopic
94+
Type: "AWS::SNS::Topic"
95+
Properties:
96+
TopicName: !Select [ 5, !Split [ ":", !Ref TopicARN ] ]
97+
98+
CloudTrailNotificationsSubscription:
99+
Type: "AWS::SNS::Subscription"
100+
Properties:
101+
TopicArn: !If [ CreateSNSTopic, !Ref CloudTrailNotificationsTopic, !Ref TopicARN ]
102+
Protocol: "https"
103+
Endpoint: !Ref Endpoint
104+
105+
CloudTrailNotificationsPolicy:
106+
Condition: CreateSNSTopic
107+
Type: "AWS::SNS::TopicPolicy"
108+
Properties:
109+
Topics:
110+
- !Ref CloudTrailNotificationsTopic
111+
PolicyDocument:
112+
Version: "2012-10-17"
113+
Statement:
114+
- Sid: "AllowCloudTrailPublish"
115+
Effect: "Allow"
116+
Principal:
117+
Service: "cloudtrail.amazonaws.com"
118+
Action: "SNS:Publish"
119+
Resource: !Ref CloudTrailNotificationsTopic
68120
Policies:
69121
- PolicyName: !Sub ${CSPMRoleName}
70122
PolicyDocument:
@@ -128,7 +180,7 @@ Resources:
128180
- !Sub '${BucketARN}'
129181
- !Sub '${BucketARN}/*'
130182
Roles:
131-
- Ref: "CloudLogsRole"
183+
- !Ref CloudLogsRole
132184
RolesStackSet:
133185
Type: AWS::CloudFormation::StackSet
134186
Properties:
@@ -213,3 +265,14 @@ Resources:
213265
- Effect: "Allow"
214266
Action: "account:GetContactInformation"
215267
Resource: "*"
268+
Conditions:
269+
CreateSNSTopic: !Equals [ !Ref CreateTopic, "true" ]
270+
271+
Outputs:
272+
RoleARN:
273+
Description: "The ARN of the IAM Role created for CloudTrail logs."
274+
Value: !GetAtt CloudLogsRole.Arn
275+
276+
TopicARN:
277+
Description: "The ARN of the SNS Topic created for CloudTrail notifications."
278+
Value: !If [ CreateSNSTopic, !Ref CloudTrailNotificationsTopic, !Ref TopicARN ]

0 commit comments

Comments
 (0)