-
Notifications
You must be signed in to change notification settings - Fork 10
/
rl-read-only.yaml
246 lines (244 loc) · 8.09 KB
/
rl-read-only.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
241
242
243
244
245
246
AWSTemplateFormatVersion: '2010-09-09'
Description: Prisma IAM Role to set read permissions
Parameters:
PrismaRoleName:
Type: String
Description: 'Provide an role ARN name (Example: PrismaReadOnlyRole)'
AllowedPattern: '[-_a-zA-Z0-9]*'
Default: "PrismaReadOnlyRole"
ExternalID:
Type: String
Description: 'Provide an ExternalID (Example: Xoih821ddwf)'
MinLength: '1'
AllowedPattern: '[a-zA-Z0-9\=\,\.\@\:\/\-_]*'
ConstraintDescription: 'ExternalID must contain alphanumeric characters and only
these special characters are allowed =,.@:/-. '
PrismaUsername:
Type: String
Description: 'Provide the Prisma.io username, preferably an onboarding only account.'
MinLength: '1'
AllowedPattern: '[a-zA-Z0-9\=\,\.\@\:\/\-_]*'
PrismaPassword:
Type: String
Description: 'Password for Prisma.io'
MinLength: '1'
PrismaCustomerName:
Type: String
Description: 'The designed company name assigned within Prisma.io'
MinLength: '1'
AllowedPattern: '[a-zA-Z0-9\=\,\.\@\:\/\-_\s]*'
PrismaAccountName:
Type: String
Description: 'Provide a unique name for the AWS account within Prisma.io'
MinLength: '1'
AllowedPattern: '[a-zA-Z0-9\=\,\.\@''\:\/\-_\s]*'
PrismaTenant:
Type: String
Description: 'Specify the Prisma.io tenant your account is provisioned on'
MinLength: '1'
AllowedValues: ["app", "app2", "app3", "app.eu", "app.anz"]
PrismaAccountGroup:
Type: String
Description: 'Specify the Prisma account group name'
MinLength: '5'
AllowedPattern: '[a-zA-Z0-9\=\,\.\@\:\/\-_\s]*'
Default: 'Default Account Group'
CreatePrismaAccount:
Type: String
Description: 'Set to true to create Prisma account, set to false to just update AWS settings (including role)'
Default: 'false'
AllowedValues: ["true", "false"]
EnableCloudTrailLogs:
Type: String
Description: 'Check for multi-region trail and create a new one if one does not exist'
Default: 'false'
AllowedValues: ["true", "false"]
EnableVpcFlowLogs:
Type: String
Description: 'Enable VpcFlowLogs for each of the Vpcs in your account if one does not exist'
Default: 'false'
AllowedValues: ["true", "false"]
Conditions:
ShouldCreateCloudTrail:
!Equals [true, !Ref EnableCloudTrailLogs]
ShouldCreateVpcFlowLogs:
!Equals [true, !Ref EnableVpcFlowLogs]
ShouldCreateLambda:
Fn::Or: [Condition: ShouldCreateCloudTrail, Condition: ShouldCreateVpcFlowLogs]
Resources:
PrismaRole:
Type: AWS::IAM::Role
Properties:
ManagedPolicyArns:
- arn:aws:iam::aws:policy/SecurityAudit
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
AWS: arn:aws:iam::188619942792:root
Action: sts:AssumeRole
Condition:
StringEquals:
sts:ExternalId: !Ref 'ExternalID'
Policies:
- PolicyName: Prisma-IAM-ReadOnly-Policy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Action:
- mq:DescribeBroker
- apigateway:GET
- cognito-identity:ListTagsForResource
- cognito-idp:ListTagsForResource
- ecr:DescribeImages
- ecr:GetLifecyclePolicy
- directconnect:DescribeDirectConnectGateways
- elasticbeanstalk:ListTagsForResource
- elasticfilesystem:DescribeTags
- glacier:GetVaultLock
- glacier:ListTagsForVault
- glue:GetSecurityConfigurations
- logs:GetLogEvents
- mq:listBrokers
- mq:describeBroker
- ram:GetResourceShares
- secretsmanager:DescribeSecret
- ssm:GetParameters
- ssm:ListTagsForResource
- sqs:SendMessage
- elasticmapreduce:ListSecurityConfigurations
- sns:listSubscriptions
- wafv2:ListResourcesForWebACL
- wafv2:ListWebACLs
- waf-regional:ListResourcesForWebACL
- waf-regional:ListWebACLs-
Effect: Allow
Resource: '*'
RoleName: !Ref 'PrismaRoleName'
LambdaOnboardRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: Prisma-IAM-ReadOnly-Policy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Action:
- cloudtrail:CreateTrail
- cloudtrail:GetTrailStatus
- cloudtrail:GetEventSelectors
- cloudtrail:DescribeTrails
- s3:CreateBucket
- s3:ListBucketVersions
- s3:ListBucket
- s3:GetBucketPolicy
- s3:HeadBucket
- s3:ListAllMyBuckets
- s3:GetBucketPolicyStatus
- s3:GetBucketVersioning
- s3:GetBucketAcl
- sts:GetCallerIdentity
- ec2:DescribeRegions
- ec2:CreateFlowLogs
- ec2:DescribeVpcs
- ec2:DescribeFlowLogs
- logs:DescribeLogGroups
- logs:CreateLogGroup
- iam:CreatePolicy
- iam:PassRole
- iam:CreateRole
- cloudtrail:StartLogging
- iam:AttachRolePolicy
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Effect: Allow
Resource: '*'
- Action:
- s3:PutBucketPolicy
Effect: Allow
Resource: !Join
- ''
- - 'arn:aws:s3:::prismatrail-'
- !Ref 'AWS::AccountId'
LambdaFunction:
Type: AWS::Lambda::Function
Properties:
FunctionName: "LambdaOnboardPrisma"
Description: Onboarding Script for Prisma
Runtime: python3.7
Code:
S3Bucket: "onboardprisma"
S3Key: onboard.zip
Handler: onboard_rl.main
MemorySize: 128
Timeout: 900
Role:
Fn::GetAtt:
- LambdaOnboardRole
- Arn
Environment:
Variables:
PRISMA_USER_NAME:
!Ref PrismaUsername
PRISMA_PASSWORD:
!Ref PrismaPassword
PRISMA_CUSTOMER_NAME:
!Ref PrismaCustomerName
PRISMA_ACCOUNT_NAME:
!Ref PrismaAccountName
PRISMA_TENANT:
!Ref PrismaTenant
PRISMA_ACCOUNT_GROUP:
!Ref PrismaAccountGroup
PRISMA_ACCOUNT:
!Ref CreatePrismaAccount
PRISMA_CLOUDTRAIL:
!If [ShouldCreateCloudTrail, true, false]
PRISMA_VPC:
!If [ShouldCreateVpcFlowLogs, true, false]
EXTERNAL_ID:
!Ref ExternalID
ROLE_NAME:
!Ref PrismaRoleName
CF_REGION:
!Ref AWS::Region
OnboardScript:
Type: Custom::OnboardPrismaScript
Properties:
ServiceToken: !GetAtt LambdaFunction.Arn
DependsOn: LambdaFunction
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
-
Label:
default: "Prisma Account Information"
Parameters:
- PrismaUsername
- PrismaPassword
- PrismaCustomerName
- PrismaAccountName
- PrismaTenant
- PrismaAccountGroup
- CreatePrismaAccount
-
Label:
default: "AWS Configuration"
Parameters:
- PrismaRoleName
- ExternalID
- EnableCloudTrailLogs
- EnableVpcFlowLogs
Outputs:
PrismaRoleName:
Value: !Ref 'PrismaRoleName'
Description: Prisma IAM role name