Skip to content

Commit aeb0ca9

Browse files
committed
fix event bridge org
1 parent d1f6060 commit aeb0ca9

File tree

7 files changed

+610
-831
lines changed

7 files changed

+610
-831
lines changed

templates_eventbridge/EventBridge.yaml

Lines changed: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AWSTemplateFormatVersion: "2010-09-09"
2-
Description: EventBridge resources that forward CloudTrail logs to Sysdig Secure
2+
Description: EventBridge resources that forward CloudTrail logs to Sysdig Secure via API Destination
33

44
Metadata:
55
AWS::CloudFormation::Interface:
@@ -10,7 +10,9 @@ Metadata:
1010
- EventBridgeRoleName
1111
- ExternalID
1212
- TrustedIdentity
13-
- EventBusARN
13+
- ApiKey
14+
- IngestionUrl
15+
- RateLimit
1416
- EventBridgeState
1517
- EventBridgeEventPattern
1618

@@ -19,8 +21,12 @@ Metadata:
1921
default: "External ID (Sysdig use only)"
2022
TrustedIdentity:
2123
default: "Trusted Identity (Sysdig use only)"
22-
EventBusARN:
23-
default: "Target Event Bus (Sysdig use only)"
24+
ApiKey:
25+
default: "API Key (Sysdig use only)"
26+
IngestionUrl:
27+
default: "Ingestion URL (Sysdig use only)"
28+
RateLimit:
29+
default: "Rate Limit (Sysdig use only)"
2430
EventBridgeRoleName:
2531
default: "Integration Name (Sysdig use only)"
2632
EventBridgeState:
@@ -38,15 +44,21 @@ Parameters:
3844
TrustedIdentity:
3945
Type: String
4046
Description: The Role in Sysdig's AWS Account with permissions to your account
41-
EventBusARN:
47+
ApiKey:
4248
Type: String
43-
Description: The destination in Sysdig's AWS account where your events are sent
49+
Description: API key for Sysdig Secure authentication
50+
IngestionUrl:
51+
Type: String
52+
Description: Sysdig Secure API ingestion URL
53+
RateLimit:
54+
Type: Number
55+
Description: Maximum invocations per second for the API destination
56+
Default: 300
4457
EventBridgeState:
4558
Type: String
4659
Description: The state of the EventBridge Rule
47-
Default: ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS
60+
Default: ENABLED
4861
AllowedValues:
49-
- ENABLED_WITH_ALL_CLOUDTRAIL_MANAGEMENT_EVENTS
5062
- ENABLED
5163
- DISABLED
5264
EventBridgeEventPattern:
@@ -73,6 +85,25 @@ Parameters:
7385
}
7486
7587
Resources:
88+
EventBridgeConnection:
89+
Type: AWS::Events::Connection
90+
Properties:
91+
Name: !Sub ${EventBridgeRoleName}-connection
92+
AuthorizationType: API_KEY
93+
AuthParameters:
94+
ApiKeyAuthParameters:
95+
ApiKeyName: X-Api-Key
96+
ApiKeyValue: !Ref ApiKey
97+
98+
EventBridgeApiDestination:
99+
Type: AWS::Events::ApiDestination
100+
Properties:
101+
Name: !Sub ${EventBridgeRoleName}-destination
102+
ConnectionArn: !GetAtt EventBridgeConnection.Arn
103+
InvocationEndpoint: !Ref IngestionUrl
104+
HttpMethod: POST
105+
InvocationRateLimitPerSecond: !Ref RateLimit
106+
76107
EventBridgeRole:
77108
Type: AWS::IAM::Role
78109
Properties:
@@ -89,31 +120,40 @@ Resources:
89120
Action: "sts:AssumeRole"
90121
Condition:
91122
StringEquals:
92-
sts:ExternalId: !Ref ExternalID
123+
sts:ExternalId: !Ref ExternalID
93124
Policies:
94125
- PolicyName: !Ref EventBridgeRoleName
95126
PolicyDocument:
96127
Version: "2012-10-17"
97128
Statement:
98-
- Effect: Allow
99-
Action: 'events:PutEvents'
100-
Resource: !Ref EventBusARN
101-
- Effect: Allow
129+
- Sid: "InvokeApiDestination"
130+
Effect: Allow
131+
Action:
132+
- "events:InvokeApiDestination"
133+
Resource:
134+
- !Sub "arn:aws:events:*:*:api-destination/${EventBridgeRoleName}-destination/*"
135+
- Sid: "CloudTrailEventRuleAccess"
136+
Effect: Allow
102137
Action:
103138
- "events:DescribeRule"
104139
- "events:ListTargetsByRule"
105140
Resource:
106-
- !Sub arn:aws:events:*:*:rule/${EventBridgeRoleName}
141+
- !Sub "arn:aws:events:*:*:rule/${EventBridgeRoleName}"
142+
- Sid: "ValidationAccess"
143+
Effect: Allow
144+
Action:
145+
- "events:DescribeApiDestination"
146+
- "events:DescribeConnection"
147+
Resource: "*"
148+
107149
EventBridgeRule:
108150
Type: AWS::Events::Rule
109151
Properties:
110152
Name: !Ref EventBridgeRoleName
111-
Description: Capture all CloudTrail events
153+
Description: Capture all CloudTrail events for Sysdig Secure
112154
EventPattern: !Ref EventBridgeEventPattern
113155
State: !Ref EventBridgeState
114156
Targets:
115157
- Id: !Ref EventBridgeRoleName
116-
Arn: !Ref EventBusARN
117-
RoleArn: !GetAtt
118-
- EventBridgeRole
119-
- Arn
158+
Arn: !GetAtt EventBridgeApiDestination.Arn
159+
RoleArn: !GetAtt EventBridgeRole.Arn

templates_eventbridge/Makefile

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# requires AWS_PROFILE
22
# bucket must exist, prefix will be created
3-
S3_BUCKET ?= "s4c-cft"
3+
S3_BUCKET ?= "<your bucket>"
44
S3_PREFIX ?= "test"
55
# We need the REGION or the TemplateURLs might be created for a different region, resulting in a deployment error
6-
S3_REGION ?= "eu-west-1" # ireland
7-
SECURE_API_TOKEN ?= ""
6+
S3_REGION ?= "us-east-1"
7+
SECURE_API_TOKEN ?= "<sysdig token>"
88
STACK_NAME = "EventBridgeTest"
99
STACK_NAME_ORG = "OrgEventBridgeTest"
1010

@@ -30,11 +30,19 @@ packaged-template.yaml:
3030

3131
test: packaged-template.yaml
3232
aws cloudformation deploy \
33-
--stack-name $(STACK_NAME) \
33+
--stack-name "EventBridgeTest" \
3434
--template-file packaged-template.yaml \
3535
--capabilities "CAPABILITY_NAMED_IAM" "CAPABILITY_AUTO_EXPAND" \
3636
--parameter-overrides \
37-
"SysdigSecureAPIToken=$(SECURE_API_TOKEN)"
37+
"SysdigSecureAPIToken=<sysdig token>" \
38+
"ApiKey=4ba93f30-c5d2-42e8-9319-c8d23a6b174d" \
39+
"IngestionUrl=https://ingest-eu1.app.sysdig.com/api/events" \
40+
"EventBridgeRoleName=SysdigEventBridgeIntegration" \
41+
"ExternalID=bcacfba7093b0c5fce39ee8012272f07" \
42+
"TrustedIdentity=arn:aws:iam::064689838359:role/us-east-1-integration01-secure-assume-role" \
43+
"RateLimit=300" \
44+
"EventBridgeState=ENABLED" \
45+
"EventBridgeEventPattern={\"source\":[\"aws.cloudtrail\"]}"
3846

3947
ci: packaged-template.yaml
4048
aws s3 cp ./packaged-template.yaml s3://$(S3_BUCKET)/event-bridge/single/$(S3_PREFIX)/entry-point.yaml
@@ -54,11 +62,22 @@ packaged-template-org.yaml:
5462

5563
test-org: packaged-template-org.yaml
5664
aws cloudformation deploy \
57-
--stack-name $(STACK_NAME_ORG) \
65+
--region "us-east-1" \
66+
--stack-name "EventBridgeTest" \
5867
--template-file packaged-template-org.yaml \
5968
--capabilities "CAPABILITY_NAMED_IAM" "CAPABILITY_AUTO_EXPAND" \
6069
--parameter-overrides \
61-
"SysdigSecureAPIToken=$(SECURE_API_TOKEN)"
70+
"SysdigSecureAPIToken=<sysdig token>" \
71+
"ApiKey=4ba93f30-c5d2-42e8-9319-c8d23a6b174d" \
72+
"IngestionUrl=https://ingest-eu1.app.sysdig.com/api/events" \
73+
"EventBridgeRoleName=SysdigEventBridgeIntegration" \
74+
"ExternalID=bcacfba7093b0c5fce39ee8012272f07" \
75+
"TrustedIdentity=arn:aws:iam::064689838359:role/us-east-1-integration01-secure-assume-role" \
76+
"RateLimit=300" \
77+
"OrganizationUnitIDs=ou-s212-x4xr99jl,ou-s212-c5n6dwzt,ou-s212-uihli2xi" \
78+
"EventBridgeState=ENABLED" \
79+
"EventBridgeEventPattern={\"source\":[\"aws.cloudtrail\"]}" \
80+
"Regions=us-east-1,us-west-2"
6281

6382
ci-org: packaged-template-org.yaml
6483
aws s3 cp ./packaged-template-org.yaml s3://$(S3_BUCKET)/event-bridge/org/$(S3_PREFIX)/entry-point.yaml

0 commit comments

Comments
 (0)