-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpanther-cloudsec-iam.yml
More file actions
212 lines (202 loc) · 7.93 KB
/
Copy pathpanther-cloudsec-iam.yml
File metadata and controls
212 lines (202 loc) · 7.93 KB
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
AWSTemplateFormatVersion: 2010-09-09
Description: IAM roles for an account being scanned by Panther.
Mappings:
# DO NOT EDIT PantherParameters section. Panther application relies on the exact format (including comments)
# in order to replace the default values with an appropriate ones.
PantherParameters:
MasterAccountId:
Value: '' # MasterAccountId
MasterAccountRegion:
Value: '' # MasterAccountRegion
DeployCloudWatchEventSetup:
Value: '' # DeployCloudWatchEventSetup
Parameters:
# Required parameters
MasterAccountId:
Type: String
Description: DO NOT EDIT MANUALLY! Parameter is already populated with the appropriate value.
Default: ''
MasterAccountRegion:
Type: String
Description: DO NOT EDIT MANUALLY! Parameter is already populated with the appropriate value.
Default: ''
# Deployment toggles
DeployCloudWatchEventSetup:
Type: String
Description: DO NOT EDIT MANUALLY! Parameter is already populated with the appropriate value.
Default: ''
Conditions:
# Condition to define if the template is generated by panther backend
GeneratedTemplate: !Not [!Equals ['', !FindInMap [PantherParameters, MasterAccountId, Value]]]
# Condition whether the generated template has CW events setup
GeneratedCloudWatchEventSetup:
!Equals [true, !FindInMap [PantherParameters, DeployCloudWatchEventSetup, Value]]
# Condition whether the default template values configure CW events setup
DefaultCloudWatchEventSetup: !Equals [true, !Ref DeployCloudWatchEventSetup]
# Condition whether we should enable CWE
EnableCloudWatchEvent: !Or
- !And [Condition: GeneratedTemplate, Condition: GeneratedCloudWatchEventSetup]
- !And [!Not [Condition: GeneratedTemplate], Condition: DefaultCloudWatchEventSetup]
Resources:
AuditRole:
Type: AWS::IAM::Role
Properties:
RoleName: !If # DO NOT CHANGE! backend.yml CF depends on this name
- GeneratedTemplate
- !Sub
- PantherAuditRole-${Mapping}
- Mapping: !FindInMap [PantherParameters, MasterAccountRegion, Value]
- !Sub PantherAuditRole-${MasterAccountRegion}
Description: The Panther master account assumes this role for read-only security scanning
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
AWS: !If
- GeneratedTemplate
- !Sub
- 'arn:${Partition}:iam::${Mapping}:root'
- Partition: !Ref AWS::Partition
Mapping: !FindInMap [PantherParameters, MasterAccountId, Value]
- !Sub arn:${AWS::Partition}:iam::${MasterAccountId}:root
Action: sts:AssumeRole
Condition:
Bool:
aws:SecureTransport: true
ManagedPolicyArns:
- !Sub arn:${AWS::Partition}:iam::aws:policy/SecurityAudit
Policies:
# CloudFormationStackDriftDetection and CloudFormationStackDriftDetectionSupplements Policies
# are not directly required for scanning, but are required by AWS in
# order to perform CloudFormation Stack drift detection on the corresponding resource types
# If you delete those policies,
# make sure to exclude CloudFormation stacks from your cloud security source setup,
# otherwise you will be notified every 24 hours that those scans are failing.
- PolicyName: CloudFormationStackDriftDetection
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- cloudformation:DetectStackDrift
- cloudformation:DetectStackResourceDrift
Resource: '*'
- PolicyName: CloudFormationStackDriftDetectionSupplements
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- sns:GetDataProtectionPolicy
- sns:ListTagsForResource
- lambda:GetFunction
- apigateway:GET
Resource: '*'
- PolicyName: GetWAFACLs
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- waf:GetRateBasedRule
- waf:GetRule
- waf:GetRuleGroup
- waf:GetWebACL
- waf-regional:GetRateBasedRule
- waf-regional:GetRule
- waf-regional:GetRuleGroup
- waf-regional:GetWebACL
- waf-regional:GetWebACLForResource
Resource: '*'
- PolicyName: GetTags
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- dynamodb:ListTagsOfResource
- kms:ListResourceTags
- waf:ListTagsForResource
- waf-regional:ListTagsForResource
Resource: '*'
- PolicyName: ListDescribeEKS
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- eks:ListClusters
- eks:ListFargateProfiles
- eks:ListNodegroups
- eks:DescribeCluster
- eks:DescribeFargateProfile
- eks:DescribeNodegroup
Resource: '*'
- PolicyName: DescribeDynamodb
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- dynamodb:Describe*
Resource: '*'
Tags:
- Key: panther:app
Value: panther
CloudFormationStackSetExecutionRole:
Condition: EnableCloudWatchEvent
Type: AWS::IAM::Role
Properties:
RoleName: !If # DO NOT CHANGE! backend.yml CF depends on this name
- GeneratedTemplate
- !Sub
- PantherCloudFormationStackSetExecutionRole-${Mapping}
- Mapping: !FindInMap [PantherParameters, MasterAccountRegion, Value]
- !Sub PantherCloudFormationStackSetExecutionRole-${MasterAccountRegion}
Description: CloudFormation assumes this role to execute a stack set
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
AWS: !If
- GeneratedTemplate
- !Sub
- 'arn:${Partition}:iam::${Mapping}:root'
- Partition: !Ref AWS::Partition
Mapping: !FindInMap [PantherParameters, MasterAccountId, Value]
- !Sub arn:${AWS::Partition}:iam::${MasterAccountId}:root
Action: sts:AssumeRole
Policies:
- PolicyName: ManageCloudFormationStack
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action: cloudformation:*
Resource: '*'
- PolicyName: PantherSetupRealTimeEvents
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- events:*
- sns:*
Resource: '*'
Tags:
- Key: panther:app
Value: panther
Outputs:
AuditRoleARN:
Description: The ARN of the Panther Audit IAM Role
Value: !GetAtt AuditRole.Arn
CloudFormationStackSetExecutionRoleArn:
Condition: EnableCloudWatchEvent
Description: The Arn of the CloudFormation StackSet Execution Role for configuring Panther infra.
Value: !GetAtt CloudFormationStackSetExecutionRole.Arn
CloudFormationStackSetExecutionRoleName:
Condition: EnableCloudWatchEvent
Description: The name of the CloudFormation StackSet Execution Role for configuring Panther infra.
Value: !Ref CloudFormationStackSetExecutionRole