Skip to content

Commit 6a774e4

Browse files
single onboarding changes
1 parent d4d3233 commit 6a774e4

File tree

1 file changed

+84
-7
lines changed

1 file changed

+84
-7
lines changed

templates_cloudlogs/CloudLogs.yaml

Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
AWSTemplateFormatVersion: "2010-09-09"
22
Description: >
3-
CloudFormation single template for provisioning
4-
the necessary resources for the `cloud-logs`
5-
component.
3+
CloudFormation template for provisioning the necessary resources for the
4+
`cloud-logs` component. This includes IAM roles, policies, and optional SNS
5+
topic and subscription for CloudTrail notifications.
66
77
Metadata:
88
AWS::CloudFormation::Interface:
@@ -14,6 +14,9 @@ Metadata:
1414
- ExternalID
1515
- TrustedIdentity
1616
- BucketARN
17+
- CreateTopic
18+
- TopicARN
19+
- Endpoint
1720

1821
ParameterLabels:
1922
CloudLogsRoleName:
@@ -24,22 +27,50 @@ 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
CloudLogsRoleName:
3039
Type: String
31-
Description: The name of the IAM Role that will enable access to the Cloudtrail logs.
40+
Description: The name of the IAM Role that will enable access to the CloudTrail logs.
41+
3242
ExternalID:
3343
Type: String
3444
Description: Random string generated unique to a customer.
45+
3546
TrustedIdentity:
3647
Type: String
37-
Description: The name of Sysdig trusted identity.
48+
Description: The name of Sysdig's trusted identity.
49+
3850
BucketARN:
3951
Type: String
40-
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+
54+
CreateTopic:
55+
Type: String
56+
AllowedValues:
57+
- "true"
58+
- "false"
59+
Default: "false"
60+
Description: "Whether to create a new SNS Topic for CloudTrail notifications."
61+
62+
TopicARN:
63+
Type: String
64+
Default: ""
65+
Description: "The ARN of an existing SNS Topic. Ignored if CreateTopic is set to true."
66+
67+
Endpoint:
68+
Type: String
69+
Default: ""
70+
Description: "Sysdig Secure endpoint to receive CloudTrail notifications."
4171

4272
Resources:
73+
# IAM Role
4374
CloudLogsRole:
4475
Type: "AWS::IAM::Role"
4576
Properties:
@@ -55,6 +86,8 @@ Resources:
5586
Condition:
5687
StringEquals:
5788
"sts:ExternalId": !Ref ExternalID
89+
90+
# IAM Policy
5891
CloudLogsRolePolicies:
5992
Type: "AWS::IAM::Policy"
6093
Properties:
@@ -77,4 +110,48 @@ Resources:
77110
- !Sub '${BucketARN}'
78111
- !Sub '${BucketARN}/*'
79112
Roles:
80-
- Ref: "CloudLogsRole"
113+
- !Ref CloudLogsRole
114+
115+
# SNS Topic (optional creation)
116+
CloudTrailNotificationsTopic:
117+
Condition: CreateSNSTopic
118+
Type: "AWS::SNS::Topic"
119+
Properties:
120+
TopicName: !Sub "${AWS::StackName}-CloudTrailNotifications"
121+
DisplayName: "CloudTrail Notifications for Sysdig"
122+
123+
CloudTrailNotificationsSubscription:
124+
Condition: CreateSNSTopic
125+
Type: "AWS::SNS::Subscription"
126+
Properties:
127+
TopicArn: !Ref CloudTrailNotificationsTopic
128+
Protocol: "https"
129+
Endpoint: '${Endpoint}'
130+
131+
CloudTrailNotificationsPolicy:
132+
Condition: CreateSNSTopic
133+
Type: "AWS::SNS::TopicPolicy"
134+
Properties:
135+
Topics:
136+
- !Ref CloudTrailNotificationsTopic
137+
PolicyDocument:
138+
Version: "2012-10-17"
139+
Statement:
140+
- Sid: "AllowCloudTrailPublish"
141+
Effect: "Allow"
142+
Principal:
143+
Service: "cloudtrail.amazonaws.com"
144+
Action: "SNS:Publish"
145+
Resource: !Ref CloudTrailNotificationsTopic
146+
147+
Conditions:
148+
CreateSNSTopic: !Equals [!Ref CreateTopic, "true"]
149+
150+
Outputs:
151+
RoleARN:
152+
Description: "The ARN of the IAM Role created for CloudTrail logs."
153+
Value: !GetAtt CloudLogsRole.Arn
154+
155+
TopicARN:
156+
Description: "The ARN of the SNS Topic created for CloudTrail notifications."
157+
Value: !If [CreateSNSTopic, !Ref CloudTrailNotificationsTopic, !Ref TopicARN]

0 commit comments

Comments
 (0)