@friggframework/devtools 2.0.0-next.27 → 2.0.0-next.29

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.
Files changed (34) hide show
  1. package/frigg-cli/build-command/index.js +4 -2
  2. package/frigg-cli/deploy-command/index.js +5 -2
  3. package/frigg-cli/generate-iam-command.js +115 -0
  4. package/frigg-cli/index.js +11 -1
  5. package/infrastructure/AWS-DISCOVERY-TROUBLESHOOTING.md +245 -0
  6. package/infrastructure/AWS-IAM-CREDENTIAL-NEEDS.md +596 -0
  7. package/infrastructure/DEPLOYMENT-INSTRUCTIONS.md +268 -0
  8. package/infrastructure/GENERATE-IAM-DOCS.md +253 -0
  9. package/infrastructure/IAM-POLICY-TEMPLATES.md +176 -0
  10. package/infrastructure/README-TESTING.md +332 -0
  11. package/infrastructure/README.md +421 -0
  12. package/infrastructure/WEBSOCKET-CONFIGURATION.md +105 -0
  13. package/infrastructure/__tests__/fixtures/mock-aws-resources.js +391 -0
  14. package/infrastructure/__tests__/helpers/test-utils.js +277 -0
  15. package/infrastructure/aws-discovery.js +568 -0
  16. package/infrastructure/aws-discovery.test.js +373 -0
  17. package/infrastructure/build-time-discovery.js +206 -0
  18. package/infrastructure/build-time-discovery.test.js +375 -0
  19. package/infrastructure/create-frigg-infrastructure.js +2 -2
  20. package/infrastructure/frigg-deployment-iam-stack.yaml +379 -0
  21. package/infrastructure/iam-generator.js +687 -0
  22. package/infrastructure/iam-generator.test.js +169 -0
  23. package/infrastructure/iam-policy-basic.json +212 -0
  24. package/infrastructure/iam-policy-full.json +282 -0
  25. package/infrastructure/integration.test.js +383 -0
  26. package/infrastructure/run-discovery.js +110 -0
  27. package/infrastructure/serverless-template.js +537 -212
  28. package/infrastructure/serverless-template.test.js +541 -0
  29. package/management-ui/dist/assets/FriggLogo-B7Xx8ZW1.svg +1 -0
  30. package/management-ui/dist/assets/index-BA21WgFa.js +1221 -0
  31. package/management-ui/dist/assets/index-CbM64Oba.js +1221 -0
  32. package/management-ui/dist/assets/index-CkvseXTC.css +1 -0
  33. package/management-ui/dist/index.html +14 -0
  34. package/package.json +9 -5
@@ -0,0 +1,379 @@
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
+ - 's3:PutBucketTagging'
123
+ - 's3:GetBucketTagging'
124
+ Resource:
125
+ - 'arn:aws:s3:::*serverless*'
126
+ - 'arn:aws:s3:::*serverless*/*'
127
+
128
+ # Lambda function permissions
129
+ - Sid: 'LambdaFriggFunctions'
130
+ Effect: Allow
131
+ Action:
132
+ - 'lambda:CreateFunction'
133
+ - 'lambda:UpdateFunctionCode'
134
+ - 'lambda:UpdateFunctionConfiguration'
135
+ - 'lambda:DeleteFunction'
136
+ - 'lambda:GetFunction'
137
+ - 'lambda:ListFunctions'
138
+ - 'lambda:PublishVersion'
139
+ - 'lambda:CreateAlias'
140
+ - 'lambda:UpdateAlias'
141
+ - 'lambda:DeleteAlias'
142
+ - 'lambda:GetAlias'
143
+ - 'lambda:AddPermission'
144
+ - 'lambda:RemovePermission'
145
+ - 'lambda:GetPolicy'
146
+ - 'lambda:PutProvisionedConcurrencyConfig'
147
+ - 'lambda:DeleteProvisionedConcurrencyConfig'
148
+ - 'lambda:PutConcurrency'
149
+ - 'lambda:DeleteConcurrency'
150
+ - 'lambda:TagResource'
151
+ - 'lambda:UntagResource'
152
+ - 'lambda:ListVersionsByFunction'
153
+ Resource:
154
+ - !Sub 'arn:aws:lambda:*:${AWS::AccountId}:function:*frigg*'
155
+
156
+ # Lambda EventSourceMapping permissions
157
+ - Sid: 'FriggLambdaEventSourceMapping'
158
+ Effect: Allow
159
+ Action:
160
+ - 'lambda:CreateEventSourceMapping'
161
+ - 'lambda:DeleteEventSourceMapping'
162
+ - 'lambda:GetEventSourceMapping'
163
+ - 'lambda:UpdateEventSourceMapping'
164
+ - 'lambda:ListEventSourceMappings'
165
+ Resource:
166
+ - !Sub 'arn:aws:lambda:*:${AWS::AccountId}:event-source-mapping:*'
167
+
168
+ # IAM role permissions
169
+ - Sid: 'IAMRolesForFriggLambda'
170
+ Effect: Allow
171
+ Action:
172
+ - 'iam:CreateRole'
173
+ - 'iam:DeleteRole'
174
+ - 'iam:GetRole'
175
+ - 'iam:PassRole'
176
+ - 'iam:PutRolePolicy'
177
+ - 'iam:DeleteRolePolicy'
178
+ - 'iam:GetRolePolicy'
179
+ - 'iam:AttachRolePolicy'
180
+ - 'iam:DetachRolePolicy'
181
+ - 'iam:TagRole'
182
+ - 'iam:UntagRole'
183
+ Resource:
184
+ - !Sub 'arn:aws:iam::${AWS::AccountId}:role/*frigg*'
185
+ - !Sub 'arn:aws:iam::${AWS::AccountId}:role/*frigg*LambdaRole*'
186
+
187
+ # IAM policy permissions
188
+ - Sid: 'IAMPolicyVersionPermissions'
189
+ Effect: Allow
190
+ Action:
191
+ - 'iam:ListPolicyVersions'
192
+ Resource:
193
+ - !Sub 'arn:aws:iam::${AWS::AccountId}:policy/*'
194
+
195
+ # SQS permissions
196
+ - Sid: 'FriggMessagingServices'
197
+ Effect: Allow
198
+ Action:
199
+ - 'sqs:CreateQueue'
200
+ - 'sqs:DeleteQueue'
201
+ - 'sqs:GetQueueAttributes'
202
+ - 'sqs:SetQueueAttributes'
203
+ - 'sqs:GetQueueUrl'
204
+ - 'sqs:TagQueue'
205
+ - 'sqs:UntagQueue'
206
+ Resource:
207
+ - !Sub 'arn:aws:sqs:*:${AWS::AccountId}:*frigg*'
208
+ - !Sub 'arn:aws:sqs:*:${AWS::AccountId}:internal-error-queue-*'
209
+
210
+ # SNS permissions
211
+ - Sid: 'FriggSNSTopics'
212
+ Effect: Allow
213
+ Action:
214
+ - 'sns:CreateTopic'
215
+ - 'sns:DeleteTopic'
216
+ - 'sns:GetTopicAttributes'
217
+ - 'sns:SetTopicAttributes'
218
+ - 'sns:Subscribe'
219
+ - 'sns:Unsubscribe'
220
+ - 'sns:ListSubscriptionsByTopic'
221
+ - 'sns:TagResource'
222
+ - 'sns:UntagResource'
223
+ Resource:
224
+ - !Sub 'arn:aws:sns:*:${AWS::AccountId}:*frigg*'
225
+
226
+ # CloudWatch and Logs permissions
227
+ - Sid: 'FriggMonitoringAndLogs'
228
+ Effect: Allow
229
+ Action:
230
+ - 'cloudwatch:PutMetricAlarm'
231
+ - 'cloudwatch:DeleteAlarms'
232
+ - 'cloudwatch:DescribeAlarms'
233
+ - 'logs:CreateLogGroup'
234
+ - 'logs:CreateLogStream'
235
+ - 'logs:DeleteLogGroup'
236
+ - 'logs:DescribeLogGroups'
237
+ - 'logs:DescribeLogStreams'
238
+ - 'logs:FilterLogEvents'
239
+ - 'logs:PutLogEvents'
240
+ - 'logs:PutRetentionPolicy'
241
+ Resource:
242
+ - !Sub 'arn:aws:logs:*:${AWS::AccountId}:log-group:/aws/lambda/*frigg*'
243
+ - !Sub 'arn:aws:logs:*:${AWS::AccountId}:log-group:/aws/lambda/*frigg*:*'
244
+ - !Sub 'arn:aws:cloudwatch:*:${AWS::AccountId}:alarm:*frigg*'
245
+
246
+ # API Gateway permissions
247
+ - Sid: 'FriggAPIGateway'
248
+ Effect: Allow
249
+ Action:
250
+ - 'apigateway:POST'
251
+ - 'apigateway:PUT'
252
+ - 'apigateway:DELETE'
253
+ - 'apigateway:GET'
254
+ - 'apigateway:PATCH'
255
+ Resource:
256
+ - 'arn:aws:apigateway:*::/restapis'
257
+ - 'arn:aws:apigateway:*::/restapis/*'
258
+ - 'arn:aws:apigateway:*::/domainnames'
259
+ - 'arn:aws:apigateway:*::/domainnames/*'
260
+
261
+ # VPC-specific permissions
262
+ FriggVPCPolicy:
263
+ Type: AWS::IAM::ManagedPolicy
264
+ Condition: CreateVPCPermissions
265
+ Properties:
266
+ ManagedPolicyName: 'FriggVPCPolicy'
267
+ Description: 'VPC-related permissions for Frigg applications'
268
+ PolicyDocument:
269
+ Version: '2012-10-17'
270
+ Statement:
271
+ - Sid: 'FriggVPCEndpointManagement'
272
+ Effect: Allow
273
+ Action:
274
+ - 'ec2:CreateVpcEndpoint'
275
+ - 'ec2:DeleteVpcEndpoints'
276
+ - 'ec2:DescribeVpcEndpoints'
277
+ - 'ec2:ModifyVpcEndpoint'
278
+ - 'ec2:CreateNatGateway'
279
+ - 'ec2:DeleteNatGateway'
280
+ - 'ec2:DescribeNatGateways'
281
+ - 'ec2:AllocateAddress'
282
+ - 'ec2:ReleaseAddress'
283
+ - 'ec2:DescribeAddresses'
284
+ - 'ec2:CreateRouteTable'
285
+ - 'ec2:DeleteRouteTable'
286
+ - 'ec2:DescribeRouteTables'
287
+ - 'ec2:CreateRoute'
288
+ - 'ec2:DeleteRoute'
289
+ - 'ec2:AssociateRouteTable'
290
+ - 'ec2:DisassociateRouteTable'
291
+ - 'ec2:CreateSecurityGroup'
292
+ - 'ec2:DeleteSecurityGroup'
293
+ - 'ec2:AuthorizeSecurityGroupEgress'
294
+ - 'ec2:AuthorizeSecurityGroupIngress'
295
+ - 'ec2:RevokeSecurityGroupEgress'
296
+ - 'ec2:RevokeSecurityGroupIngress'
297
+ - 'ec2:CreateTags'
298
+ - 'ec2:DeleteTags'
299
+ - 'ec2:DescribeTags'
300
+ Resource: '*'
301
+
302
+ # KMS permissions
303
+ FriggKMSPolicy:
304
+ Type: AWS::IAM::ManagedPolicy
305
+ Condition: CreateKMSPermissions
306
+ Properties:
307
+ ManagedPolicyName: 'FriggKMSPolicy'
308
+ Description: 'KMS encryption permissions for Frigg applications'
309
+ PolicyDocument:
310
+ Version: '2012-10-17'
311
+ Statement:
312
+ - Sid: 'FriggKMSEncryptionRuntime'
313
+ Effect: Allow
314
+ Action:
315
+ - 'kms:GenerateDataKey'
316
+ - 'kms:Decrypt'
317
+ Resource:
318
+ - !Sub 'arn:aws:kms:*:${AWS::AccountId}:key/*'
319
+ Condition:
320
+ StringEquals:
321
+ 'kms:ViaService':
322
+ - 'lambda.*.amazonaws.com'
323
+ - 's3.*.amazonaws.com'
324
+
325
+ # SSM Parameter Store permissions
326
+ FriggSSMPolicy:
327
+ Type: AWS::IAM::ManagedPolicy
328
+ Condition: CreateSSMPermissions
329
+ Properties:
330
+ ManagedPolicyName: 'FriggSSMPolicy'
331
+ Description: 'SSM Parameter Store permissions for Frigg applications'
332
+ PolicyDocument:
333
+ Version: '2012-10-17'
334
+ Statement:
335
+ - Sid: 'FriggSSMParameterAccess'
336
+ Effect: Allow
337
+ Action:
338
+ - 'ssm:GetParameter'
339
+ - 'ssm:GetParameters'
340
+ - 'ssm:GetParametersByPath'
341
+ Resource:
342
+ - !Sub 'arn:aws:ssm:*:${AWS::AccountId}:parameter/*frigg*'
343
+ - !Sub 'arn:aws:ssm:*:${AWS::AccountId}:parameter/*frigg*/*'
344
+
345
+ # Store access key in Secrets Manager
346
+ FriggDeploymentCredentials:
347
+ Type: AWS::SecretsManager::Secret
348
+ Properties:
349
+ Name: 'frigg-deployment-credentials'
350
+ Description: 'Access credentials for Frigg deployment user'
351
+ SecretString: !Sub |
352
+ {
353
+ "AccessKeyId": "${FriggDeploymentAccessKey}",
354
+ "SecretAccessKey": "${FriggDeploymentAccessKey.SecretAccessKey}"
355
+ }
356
+
357
+ Outputs:
358
+ DeploymentUserArn:
359
+ Description: 'ARN of the Frigg deployment user'
360
+ Value: !GetAtt FriggDeploymentUser.Arn
361
+ Export:
362
+ Name: !Sub '${AWS::StackName}-UserArn'
363
+
364
+ AccessKeyId:
365
+ Description: 'Access Key ID for the deployment user'
366
+ Value: !Ref FriggDeploymentAccessKey
367
+ Export:
368
+ Name: !Sub '${AWS::StackName}-AccessKeyId'
369
+
370
+ SecretAccessKeyCommand:
371
+ Description: 'Command to retrieve the secret access key'
372
+ Value: !Sub |
373
+ aws secretsmanager get-secret-value --secret-id frigg-deployment-credentials --query SecretString --output text | jq -r .SecretAccessKey
374
+
375
+ CredentialsSecretArn:
376
+ Description: 'ARN of the secret containing deployment credentials'
377
+ Value: !Ref FriggDeploymentCredentials
378
+ Export:
379
+ Name: !Sub '${AWS::StackName}-CredentialsSecretArn'