-
Notifications
You must be signed in to change notification settings - Fork 0
/
instrumentation.yaml
240 lines (220 loc) · 9.01 KB
/
instrumentation.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# Edited this to add Exports for MacroName and LogGroup required for CDK automation
AWSTemplateFormatVersion: 2010-09-09
Description: Sysdig Serverless Instrumentation Stack (ReleaseVersion:5.0.1, ServerlessAgentBuild:2115, AgentBuild:5.0.1-rc4, GitRev:14024c2)
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Orchestrator Agent Settings
Parameters:
- SysdigOrchestratorAgentHost
- SysdigOrchestratorAgentPort
- Label:
default: Instrumentation Settings
Parameters:
- SysdigMacroName
- SysdigInstrumentationLogLevel
- SysdigServerlessPatcherImage
- SysdigWorkloadAgentImage
- Label:
default: Instrumentation Resource Allocation
Parameters:
- SysdigPriority
- SysdigSidecarEssential
- SysdigSidecarCpu
- SysdigSidecarMemoryLimit
- SysdigSidecarMemoryReservation
ParameterLabels:
# Orchestrator Settings
SysdigOrchestratorAgentHost:
default: Orchestrator Agent Host
SysdigOrchestratorAgentPort:
default: Orchestartor Agent Port
# Instrumentation Settings
SysdigMacroName:
default: Macro Name
SysdigInstrumentationLogLevel:
default: Sysdig Instrumentation Logging Level
SysdigServerlessPatcherImage:
default: Sysdig Serverless Patcher Image
SysdigWorkloadAgentImage:
default: Sysdig Workload Agent Image
# Instrumentation Resource Allocation
SysdigPriority:
default: Instrumentation priority
SysdigSidecarEssential:
default: Sidecar Essential Flag
SysdigSidecarCpu:
default: Sidecar CPU Units
SysdigSidecarMemoryLimit:
default: Sidecar Memory Limit
SysdigSidecarMemoryReservation:
default: Sidecar Memory Reservation
Parameters:
# Orchestrator Agent Settings
SysdigOrchestratorAgentHost:
Type: String
SysdigOrchestratorAgentPort:
Type: String
Default: "6667"
AllowedPattern: ^[0-9]+$
ConstraintDescription: Orchestrator Agent Port can include only numbers
# Instrumentation Settings
SysdigMacroName:
Type: String
Description: Must be unique within your account
AllowedPattern: ^[A-Za-z0-9]+$
Default: "SysdigMacro"
ConstraintDescription: Macro Name can include only letters and numbers
SysdigInstrumentationLogLevel:
Type: String
Default: "info"
AllowedValues:
- "silent"
- "error"
- "warning"
- "info"
- "debug"
- "trace"
SysdigServerlessPatcherImage:
Type: String
Description: Will patch your template to install the Sysdig Workload Agent - Must be hosted on an ECR private registry
Default: "quay.io/sysdig/serverless-patcher:5.0.1"
SysdigWorkloadAgentImage:
Type: String
Description: The Sysdig Agent that will secure your workload
Default: "quay.io/sysdig/workload-agent:5.0.1"
SysdigPriority:
Type: String
Description: "Instrumentation priority. If set to security, the instrumentation will prevent an unsecured workload from running."
Default: "availability"
AllowedValues:
- "security"
- "availability"
SysdigSidecarEssential:
Type: String
Description: "If true, the sidecar container will be marked as essential. If false, the sidecar container will be marked as non-essential. If set to auto, will follow the selected priority (true for security, false for availability)"
Default: "auto"
AllowedValues:
- "auto"
- "true"
- "false"
SysdigSidecarCpu:
Type: String
Description: "The number of cpu units to reserve for the sidecar container. This is optional, but if specified, it must be a positive integer."
Default: ""
AllowedPattern: ^[0-9]*$
ConstraintDescription: Sidecar CPU can include only numbers
SysdigSidecarMemoryLimit:
Type: String
Description: "The amount of memory (in MiB) to limit the sidecar container to. This is optional, but if specified, it must be a positive integer."
Default: ""
AllowedPattern: ^[0-9]*$
ConstraintDescription: Sidecar Memory Limit can include only numbers
SysdigSidecarMemoryReservation:
Type: String
Description: "The amount of memory (in MiB) to reserve for the sidecar container. This is optional, but if specified, it must be a positive integer."
Default: ""
AllowedPattern: ^[0-9]*$
ConstraintDescription: Sidecar Memory Reservation can include only numbers
Mappings:
Sysdig:
Collector:
SysdigAccessKey: ""
SysdigCollectorHost: ""
SysdigCollectorPort: ""
Agent:
NiceValueIncrement: ""
SidecarMode: ""
Kilt:
Mode:
OptIn: ""
Customization:
Definition: ""
DefinitionType: ""
RecipeConfiguration: ""
Conditions:
IsSysdigDirectConnection: !And
- !Not [!Equals [!FindInMap [Sysdig, Collector, SysdigAccessKey], "" ]]
- !Not [!Equals [!FindInMap [Sysdig, Collector, SysdigCollectorHost], "" ]]
- !Not [!Equals [!FindInMap [Sysdig, Collector, SysdigCollectorPort], "" ]]
IsKiltModeOptIn: !Equals [!FindInMap [Kilt, Mode, OptIn], "true"]
IsKiltCustomDefinition: !And
- !Not [!Equals [!FindInMap [Kilt, Customization, Definition], ""]]
- !Not [!Equals [!FindInMap [Kilt, Customization, DefinitionType], ""]]
IsKiltCustomRecipeConfiguration: !Not [ !Equals [!FindInMap [Kilt, Customization, RecipeConfiguration], ""]]
DoSetNiceValueIncrement: !Not [ !Equals [!FindInMap [Sysdig, Agent, NiceValueIncrement], ""]]
DoSetSidecarMode: !Not [ !Equals [!FindInMap [Sysdig, Agent, SidecarMode], ""]]
IsSidecarEssentialAuto: !Equals [!Ref SysdigSidecarEssential, "auto"]
IsPrioritySecurity: !Equals [!Ref SysdigPriority, "security"]
Outputs:
SysdigTransformationMacro:
Description: Add this transformation macro at the root level of your template
Value: !Sub 'Transform: ["${SysdigMacroName}"]'
Export:
Name: SysdigMacroName
SysdigLogGroup:
Description: Log group that our agent logs in each task will go
Value: !Ref SysdigLogGroup
Export:
Name: SysdigLogGroup
Resources:
SysdigLogGroup:
Type: AWS::Logs::LogGroup
Properties:
RetentionInDays: 365
ServerlessPatcherRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
ManagedPolicyArns:
- "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
ServerlessPatcherLambda:
Type: AWS::Lambda::Function
Properties:
PackageType: Image
Role: !GetAtt ServerlessPatcherRole.Arn
Code:
ImageUri: !Ref SysdigServerlessPatcherImage
Environment:
Variables:
# Sysdig Orchestrator Agent
SYSDIG_ORCHESTRATOR_HOST: !Ref SysdigOrchestratorAgentHost
SYSDIG_ORCHESTRATOR_PORT: !Ref SysdigOrchestratorAgentPort
# Sysdig Instrumentation
SYSDIG_WORKLOAD_AGENT_IMAGE: !Ref SysdigWorkloadAgentImage
SYSDIG_LOGGING: !Ref SysdigInstrumentationLogLevel
SYSDIG_PRIORITY: !Ref SysdigPriority
KILT_LOG_GROUP: !Ref SysdigLogGroup
# Sysdig Collector
SYSDIG_ACCESS_KEY: !If [IsSysdigDirectConnection, !FindInMap [Sysdig, Collector, SysdigAccessKey], !Ref AWS::NoValue]
SYSDIG_COLLECTOR_HOST: !If [IsSysdigDirectConnection, !FindInMap [Sysdig, Collector, SysdigCollectorHost], !Ref AWS::NoValue]
SYSDIG_COLLECTOR_PORT: !If [IsSysdigDirectConnection, !FindInMap [Sysdig, Collector, SysdigCollectorPort], !Ref AWS::NoValue]
# Sysdig Agent Nice Value Increment
SYSDIG_AGENT_NICE_VALUE_INCREMENT: !If [DoSetNiceValueIncrement, !FindInMap [Sysdig, Agent, NiceValueIncrement], !Ref AWS::NoValue]
# Sidecar mode
SYSDIG_SIDECAR_MODE: !If [DoSetSidecarMode, !FindInMap [Sysdig, Agent, SidecarMode], "auto"]
# Kilt OptIn Mode
KILT_OPT_IN: !If [IsKiltModeOptIn, "YES", !Ref AWS::NoValue]
# Kilt Definition/Recipe Customization
KILT_DEFINITION: !If [IsKiltCustomDefinition, !FindInMap [Kilt, Customization, Definition], !Ref AWS::NoValue]
KILT_DEFINITION_TYPE: !If [IsKiltCustomDefinition, !FindInMap [Kilt, Customization, DefinitionType], !Ref AWS::NoValue]
KILT_RECIPE_CONFIG: !If [IsKiltCustomRecipeConfiguration, !FindInMap [Kilt, Customization, RecipeConfiguration], !Ref AWS::NoValue]
KILT_SIDECAR_ESSENTIAL: !If [ IsSidecarEssentialAuto, !If [ IsPrioritySecurity, "true", "false"], !Ref SysdigSidecarEssential ]
KILT_SIDECAR_CPU: !Ref SysdigSidecarCpu
KILT_SIDECAR_MEMORY_LIMIT: !Ref SysdigSidecarMemoryLimit
KILT_SIDECAR_MEMORY_RESERVATION: !Ref SysdigSidecarMemoryReservation
ServerlessPatcherMacro:
Type: AWS::CloudFormation::Macro
Properties:
Name: !Ref SysdigMacroName
Description: Applies Sysdig instrumentation to Fargate ECS Tasks
FunctionName: !GetAtt ServerlessPatcherLambda.Arn