@friggframework/devtools 2.0.0--canary.398.e2147f7.0 → 2.0.0--canary.398.c9e5d61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,370 @@
1
+ AWSTemplateFormatVersion: '2010-09-09'
2
+ Description: 'IAM roles and policies for Frigg application deployment pipeline'
3
+
4
+ Parameters:
5
+ DeploymentUserName:
6
+ Type: String
7
+ Default: 'frigg-deployment-user'
8
+ Description: 'Name for the IAM user that will deploy Frigg applications'
9
+
10
+ EnableVPCSupport:
11
+ Type: String
12
+ Default: 'true'
13
+ AllowedValues: ['true', 'false']
14
+ Description: 'Enable VPC-related permissions for Frigg applications'
15
+
16
+ EnableKMSSupport:
17
+ Type: String
18
+ Default: 'true'
19
+ AllowedValues: ['true', 'false']
20
+ Description: 'Enable KMS encryption permissions for Frigg applications'
21
+
22
+ EnableSSMSupport:
23
+ Type: String
24
+ Default: 'true'
25
+ AllowedValues: ['true', 'false']
26
+ Description: 'Enable SSM Parameter Store permissions for Frigg applications'
27
+
28
+ Conditions:
29
+ CreateVPCPermissions: !Equals [!Ref EnableVPCSupport, 'true']
30
+ CreateKMSPermissions: !Equals [!Ref EnableKMSSupport, 'true']
31
+ CreateSSMPermissions: !Equals [!Ref EnableSSMSupport, 'true']
32
+
33
+ Resources:
34
+ # IAM User for deployment
35
+ FriggDeploymentUser:
36
+ Type: AWS::IAM::User
37
+ Properties:
38
+ UserName: !Ref DeploymentUserName
39
+ ManagedPolicyArns:
40
+ - !Ref FriggDiscoveryPolicy
41
+ - !Ref FriggCoreDeploymentPolicy
42
+ - !If [CreateVPCPermissions, !Ref FriggVPCPolicy, !Ref 'AWS::NoValue']
43
+ - !If [CreateKMSPermissions, !Ref FriggKMSPolicy, !Ref 'AWS::NoValue']
44
+ - !If [CreateSSMPermissions, !Ref FriggSSMPolicy, !Ref 'AWS::NoValue']
45
+
46
+ # Access key for the deployment user
47
+ FriggDeploymentAccessKey:
48
+ Type: AWS::IAM::AccessKey
49
+ Properties:
50
+ UserName: !Ref FriggDeploymentUser
51
+
52
+ # Discovery-time permissions (required for build process)
53
+ FriggDiscoveryPolicy:
54
+ Type: AWS::IAM::ManagedPolicy
55
+ Properties:
56
+ ManagedPolicyName: 'FriggDiscoveryPolicy'
57
+ Description: 'Permissions for AWS resource discovery during Frigg build process'
58
+ PolicyDocument:
59
+ Version: '2012-10-17'
60
+ Statement:
61
+ - Sid: 'AWSDiscoveryPermissions'
62
+ Effect: Allow
63
+ Action:
64
+ - 'sts:GetCallerIdentity'
65
+ - 'ec2:DescribeVpcs'
66
+ - 'ec2:DescribeSubnets'
67
+ - 'ec2:DescribeSecurityGroups'
68
+ - 'ec2:DescribeRouteTables'
69
+ - 'kms:ListKeys'
70
+ - 'kms:DescribeKey'
71
+ Resource: '*'
72
+
73
+ # Core deployment permissions
74
+ FriggCoreDeploymentPolicy:
75
+ Type: AWS::IAM::ManagedPolicy
76
+ Properties:
77
+ ManagedPolicyName: 'FriggCoreDeploymentPolicy'
78
+ Description: 'Core permissions for deploying Frigg applications'
79
+ PolicyDocument:
80
+ Version: '2012-10-17'
81
+ Statement:
82
+ # CloudFormation permissions
83
+ - Sid: 'CloudFormationFriggStacks'
84
+ Effect: Allow
85
+ Action:
86
+ - 'cloudformation:CreateStack'
87
+ - 'cloudformation:UpdateStack'
88
+ - 'cloudformation:DeleteStack'
89
+ - 'cloudformation:DescribeStacks'
90
+ - 'cloudformation:DescribeStackEvents'
91
+ - 'cloudformation:DescribeStackResources'
92
+ - 'cloudformation:DescribeStackResource'
93
+ - 'cloudformation:ListStackResources'
94
+ - 'cloudformation:GetTemplate'
95
+ - 'cloudformation:DescribeChangeSet'
96
+ - 'cloudformation:CreateChangeSet'
97
+ - 'cloudformation:DeleteChangeSet'
98
+ - 'cloudformation:ExecuteChangeSet'
99
+ Resource:
100
+ - !Sub 'arn:aws:cloudformation:*:${AWS::AccountId}:stack/*frigg*/*'
101
+
102
+ # ValidateTemplate needs to be allowed on all resources
103
+ - Sid: 'CloudFormationValidateTemplate'
104
+ Effect: Allow
105
+ Action:
106
+ - 'cloudformation:ValidateTemplate'
107
+ Resource: '*'
108
+
109
+ # S3 deployment bucket permissions
110
+ - Sid: 'S3DeploymentBucket'
111
+ Effect: Allow
112
+ Action:
113
+ - 's3:CreateBucket'
114
+ - 's3:PutObject'
115
+ - 's3:GetObject'
116
+ - 's3:DeleteObject'
117
+ - 's3:PutBucketPolicy'
118
+ - 's3:PutBucketVersioning'
119
+ - 's3:PutBucketPublicAccessBlock'
120
+ - 's3:GetBucketLocation'
121
+ - 's3:ListBucket'
122
+ Resource:
123
+ - 'arn:aws:s3:::*serverless*'
124
+ - 'arn:aws:s3:::*serverless*/*'
125
+
126
+ # Lambda function permissions
127
+ - Sid: 'LambdaFriggFunctions'
128
+ Effect: Allow
129
+ Action:
130
+ - 'lambda:CreateFunction'
131
+ - 'lambda:UpdateFunctionCode'
132
+ - 'lambda:UpdateFunctionConfiguration'
133
+ - 'lambda:DeleteFunction'
134
+ - 'lambda:GetFunction'
135
+ - 'lambda:ListFunctions'
136
+ - 'lambda:PublishVersion'
137
+ - 'lambda:CreateAlias'
138
+ - 'lambda:UpdateAlias'
139
+ - 'lambda:DeleteAlias'
140
+ - 'lambda:GetAlias'
141
+ - 'lambda:AddPermission'
142
+ - 'lambda:RemovePermission'
143
+ - 'lambda:GetPolicy'
144
+ - 'lambda:PutProvisionedConcurrencyConfig'
145
+ - 'lambda:DeleteProvisionedConcurrencyConfig'
146
+ - 'lambda:PutConcurrency'
147
+ - 'lambda:DeleteConcurrency'
148
+ - 'lambda:TagResource'
149
+ - 'lambda:UntagResource'
150
+ - 'lambda:ListVersionsByFunction'
151
+ Resource:
152
+ - !Sub 'arn:aws:lambda:*:${AWS::AccountId}:function:*frigg*'
153
+
154
+ # IAM role permissions
155
+ - Sid: 'IAMRolesForFriggLambda'
156
+ Effect: Allow
157
+ Action:
158
+ - 'iam:CreateRole'
159
+ - 'iam:DeleteRole'
160
+ - 'iam:GetRole'
161
+ - 'iam:PassRole'
162
+ - 'iam:PutRolePolicy'
163
+ - 'iam:DeleteRolePolicy'
164
+ - 'iam:GetRolePolicy'
165
+ - 'iam:AttachRolePolicy'
166
+ - 'iam:DetachRolePolicy'
167
+ - 'iam:TagRole'
168
+ - 'iam:UntagRole'
169
+ Resource:
170
+ - !Sub 'arn:aws:iam::${AWS::AccountId}:role/*frigg*'
171
+ - !Sub 'arn:aws:iam::${AWS::AccountId}:role/*frigg*LambdaRole*'
172
+
173
+ # IAM policy permissions
174
+ - Sid: 'IAMPolicyVersionPermissions'
175
+ Effect: Allow
176
+ Action:
177
+ - 'iam:ListPolicyVersions'
178
+ Resource:
179
+ - !Sub 'arn:aws:iam::${AWS::AccountId}:policy/*'
180
+
181
+ # SQS permissions
182
+ - Sid: 'FriggMessagingServices'
183
+ Effect: Allow
184
+ Action:
185
+ - 'sqs:CreateQueue'
186
+ - 'sqs:DeleteQueue'
187
+ - 'sqs:GetQueueAttributes'
188
+ - 'sqs:SetQueueAttributes'
189
+ - 'sqs:GetQueueUrl'
190
+ - 'sqs:TagQueue'
191
+ - 'sqs:UntagQueue'
192
+ Resource:
193
+ - !Sub 'arn:aws:sqs:*:${AWS::AccountId}:*frigg*'
194
+ - !Sub 'arn:aws:sqs:*:${AWS::AccountId}:internal-error-queue-*'
195
+
196
+ # SNS permissions
197
+ - Sid: 'FriggSNSTopics'
198
+ Effect: Allow
199
+ Action:
200
+ - 'sns:CreateTopic'
201
+ - 'sns:DeleteTopic'
202
+ - 'sns:GetTopicAttributes'
203
+ - 'sns:SetTopicAttributes'
204
+ - 'sns:Subscribe'
205
+ - 'sns:Unsubscribe'
206
+ - 'sns:ListSubscriptionsByTopic'
207
+ - 'sns:TagResource'
208
+ - 'sns:UntagResource'
209
+ Resource:
210
+ - !Sub 'arn:aws:sns:*:${AWS::AccountId}:*frigg*'
211
+
212
+ # CloudWatch and Logs permissions
213
+ - Sid: 'FriggMonitoringAndLogs'
214
+ Effect: Allow
215
+ Action:
216
+ - 'cloudwatch:PutMetricAlarm'
217
+ - 'cloudwatch:DeleteAlarms'
218
+ - 'cloudwatch:DescribeAlarms'
219
+ - 'logs:CreateLogGroup'
220
+ - 'logs:CreateLogStream'
221
+ - 'logs:DeleteLogGroup'
222
+ - 'logs:DescribeLogGroups'
223
+ - 'logs:DescribeLogStreams'
224
+ - 'logs:FilterLogEvents'
225
+ - 'logs:PutLogEvents'
226
+ - 'logs:PutRetentionPolicy'
227
+ Resource:
228
+ - !Sub 'arn:aws:logs:*:${AWS::AccountId}:log-group:/aws/lambda/*frigg*'
229
+ - !Sub 'arn:aws:logs:*:${AWS::AccountId}:log-group:/aws/lambda/*frigg*:*'
230
+ - !Sub 'arn:aws:cloudwatch:*:${AWS::AccountId}:alarm:*frigg*'
231
+
232
+ # API Gateway permissions
233
+ - Sid: 'FriggAPIGateway'
234
+ Effect: Allow
235
+ Action:
236
+ - 'apigateway:POST'
237
+ - 'apigateway:PUT'
238
+ - 'apigateway:DELETE'
239
+ - 'apigateway:GET'
240
+ - 'apigateway:PATCH'
241
+ Resource:
242
+ - 'arn:aws:apigateway:*::/restapis'
243
+ - 'arn:aws:apigateway:*::/restapis/*'
244
+ - 'arn:aws:apigateway:*::/domainnames'
245
+ - 'arn:aws:apigateway:*::/domainnames/*'
246
+
247
+ # VPC-specific permissions
248
+ FriggVPCPolicy:
249
+ Type: AWS::IAM::ManagedPolicy
250
+ Condition: CreateVPCPermissions
251
+ Properties:
252
+ ManagedPolicyName: 'FriggVPCPolicy'
253
+ Description: 'VPC-related permissions for Frigg applications'
254
+ PolicyDocument:
255
+ Version: '2012-10-17'
256
+ Statement:
257
+ - Sid: 'FriggVPCEndpointManagement'
258
+ Effect: Allow
259
+ Action:
260
+ - 'ec2:CreateVpcEndpoint'
261
+ - 'ec2:DeleteVpcEndpoint'
262
+ - 'ec2:DescribeVpcEndpoints'
263
+ - 'ec2:ModifyVpcEndpoint'
264
+ - 'ec2:CreateNatGateway'
265
+ - 'ec2:DeleteNatGateway'
266
+ - 'ec2:DescribeNatGateways'
267
+ - 'ec2:AllocateAddress'
268
+ - 'ec2:ReleaseAddress'
269
+ - 'ec2:DescribeAddresses'
270
+ - 'ec2:CreateRouteTable'
271
+ - 'ec2:DeleteRouteTable'
272
+ - 'ec2:DescribeRouteTables'
273
+ - 'ec2:CreateRoute'
274
+ - 'ec2:DeleteRoute'
275
+ - 'ec2:AssociateRouteTable'
276
+ - 'ec2:DisassociateRouteTable'
277
+ - 'ec2:CreateSecurityGroup'
278
+ - 'ec2:DeleteSecurityGroup'
279
+ - 'ec2:AuthorizeSecurityGroupEgress'
280
+ - 'ec2:AuthorizeSecurityGroupIngress'
281
+ - 'ec2:RevokeSecurityGroupEgress'
282
+ - 'ec2:RevokeSecurityGroupIngress'
283
+ Resource: '*'
284
+ Condition:
285
+ StringLike:
286
+ 'ec2:CreateAction':
287
+ - 'CreateVpcEndpoint'
288
+ - 'CreateNatGateway'
289
+ - 'CreateRouteTable'
290
+ - 'CreateRoute'
291
+ - 'CreateSecurityGroup'
292
+
293
+ # KMS permissions
294
+ FriggKMSPolicy:
295
+ Type: AWS::IAM::ManagedPolicy
296
+ Condition: CreateKMSPermissions
297
+ Properties:
298
+ ManagedPolicyName: 'FriggKMSPolicy'
299
+ Description: 'KMS encryption permissions for Frigg applications'
300
+ PolicyDocument:
301
+ Version: '2012-10-17'
302
+ Statement:
303
+ - Sid: 'FriggKMSEncryptionRuntime'
304
+ Effect: Allow
305
+ Action:
306
+ - 'kms:GenerateDataKey'
307
+ - 'kms:Decrypt'
308
+ Resource:
309
+ - !Sub 'arn:aws:kms:*:${AWS::AccountId}:key/*'
310
+ Condition:
311
+ StringEquals:
312
+ 'kms:ViaService':
313
+ - 'lambda.*.amazonaws.com'
314
+ - 's3.*.amazonaws.com'
315
+
316
+ # SSM Parameter Store permissions
317
+ FriggSSMPolicy:
318
+ Type: AWS::IAM::ManagedPolicy
319
+ Condition: CreateSSMPermissions
320
+ Properties:
321
+ ManagedPolicyName: 'FriggSSMPolicy'
322
+ Description: 'SSM Parameter Store permissions for Frigg applications'
323
+ PolicyDocument:
324
+ Version: '2012-10-17'
325
+ Statement:
326
+ - Sid: 'FriggSSMParameterAccess'
327
+ Effect: Allow
328
+ Action:
329
+ - 'ssm:GetParameter'
330
+ - 'ssm:GetParameters'
331
+ - 'ssm:GetParametersByPath'
332
+ Resource:
333
+ - !Sub 'arn:aws:ssm:*:${AWS::AccountId}:parameter/*frigg*'
334
+ - !Sub 'arn:aws:ssm:*:${AWS::AccountId}:parameter/*frigg*/*'
335
+
336
+ # Store access key in Secrets Manager
337
+ FriggDeploymentCredentials:
338
+ Type: AWS::SecretsManager::Secret
339
+ Properties:
340
+ Name: 'frigg-deployment-credentials'
341
+ Description: 'Access credentials for Frigg deployment user'
342
+ SecretString: !Sub |
343
+ {
344
+ "AccessKeyId": "${FriggDeploymentAccessKey}",
345
+ "SecretAccessKey": "${FriggDeploymentAccessKey.SecretAccessKey}"
346
+ }
347
+
348
+ Outputs:
349
+ DeploymentUserArn:
350
+ Description: 'ARN of the Frigg deployment user'
351
+ Value: !GetAtt FriggDeploymentUser.Arn
352
+ Export:
353
+ Name: !Sub '${AWS::StackName}-UserArn'
354
+
355
+ AccessKeyId:
356
+ Description: 'Access Key ID for the deployment user'
357
+ Value: !Ref FriggDeploymentAccessKey
358
+ Export:
359
+ Name: !Sub '${AWS::StackName}-AccessKeyId'
360
+
361
+ SecretAccessKeyCommand:
362
+ Description: 'Command to retrieve the secret access key'
363
+ Value: !Sub |
364
+ aws secretsmanager get-secret-value --secret-id frigg-deployment-credentials --query SecretString --output text | jq -r .SecretAccessKey
365
+
366
+ CredentialsSecretArn:
367
+ Description: 'ARN of the secret containing deployment credentials'
368
+ Value: !Ref FriggDeploymentCredentials
369
+ Export:
370
+ Name: !Sub '${AWS::StackName}-CredentialsSecretArn'