@friggframework/devtools 2.0.0--canary.398.53eac55.0 → 2.0.0--canary.397.878fefa.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.
@@ -1,561 +0,0 @@
1
- # AWS IAM Credential Requirements for Frigg Applications
2
-
3
- This document outlines the minimum AWS IAM permissions required to build and deploy Frigg applications with VPC, KMS, and SSM support.
4
-
5
- ## Overview
6
-
7
- Frigg applications require two distinct sets of permissions:
8
-
9
- 1. **Discovery-Time Permissions** - Used during the build process to discover default AWS resources
10
- 2. **Deployment-Time Permissions** - Used during actual deployment to create CloudFormation resources
11
-
12
- The AWS discovery process runs during the `before:package:initialize` serverless hook to automatically find your default VPC, subnets, security groups, and KMS keys, eliminating the need for manual resource ID lookup.
13
-
14
- ## Discovery-Time Permissions (Build Process)
15
-
16
- These permissions are required when `aws-discovery.js` runs during the build to find your default AWS resources:
17
-
18
- ```json
19
- {
20
- "Version": "2012-10-17",
21
- "Statement": [
22
- {
23
- "Sid": "AWSDiscoveryPermissions",
24
- "Effect": "Allow",
25
- "Action": [
26
- "sts:GetCallerIdentity",
27
- "ec2:DescribeVpcs",
28
- "ec2:DescribeSubnets",
29
- "ec2:DescribeSecurityGroups",
30
- "ec2:DescribeRouteTables",
31
- "kms:ListKeys",
32
- "kms:DescribeKey"
33
- ],
34
- "Resource": "*"
35
- }
36
- ]
37
- }
38
- ```
39
-
40
- ### What Each Permission Does:
41
- - **`sts:GetCallerIdentity`** - Gets your AWS account ID for KMS key ARN construction
42
- - **`ec2:DescribeVpcs`** - Finds your default VPC or first available VPC
43
- - **`ec2:DescribeSubnets`** - Identifies private subnets within your VPC
44
- - **`ec2:DescribeSecurityGroups`** - Locates default security group or Frigg-specific security group
45
- - **`ec2:DescribeRouteTables`** - Determines which subnets are private (no direct internet gateway route)
46
- - **`kms:ListKeys`** - Lists available KMS keys in your account
47
- - **`kms:DescribeKey`** - Gets details about KMS keys to find customer-managed keys
48
-
49
- ## Core Deployment Permissions
50
-
51
- Required for basic Frigg application deployment:
52
-
53
- ```json
54
- {
55
- "Version": "2012-10-17",
56
- "Statement": [
57
- {
58
- "Sid": "CloudFormationFriggStacks",
59
- "Effect": "Allow",
60
- "Action": [
61
- "cloudformation:CreateStack",
62
- "cloudformation:UpdateStack",
63
- "cloudformation:DeleteStack",
64
- "cloudformation:DescribeStacks",
65
- "cloudformation:DescribeStackEvents",
66
- "cloudformation:DescribeStackResources",
67
- "cloudformation:DescribeStackResource",
68
- "cloudformation:ListStackResources",
69
- "cloudformation:GetTemplate",
70
- "cloudformation:ValidateTemplate",
71
- "cloudformation:DescribeChangeSet",
72
- "cloudformation:CreateChangeSet",
73
- "cloudformation:DeleteChangeSet",
74
- "cloudformation:ExecuteChangeSet"
75
- ],
76
- "Resource": [
77
- "arn:aws:cloudformation:*:*:stack/*frigg*/*"
78
- ]
79
- },
80
- {
81
- "Sid": "S3DeploymentBucket",
82
- "Effect": "Allow",
83
- "Action": [
84
- "s3:CreateBucket",
85
- "s3:PutObject",
86
- "s3:GetObject",
87
- "s3:DeleteObject",
88
- "s3:PutBucketPolicy",
89
- "s3:PutBucketVersioning",
90
- "s3:PutBucketPublicAccessBlock",
91
- "s3:GetBucketLocation",
92
- "s3:ListBucket"
93
- ],
94
- "Resource": [
95
- "arn:aws:s3:::*serverless*",
96
- "arn:aws:s3:::*serverless*/*"
97
- ]
98
- },
99
- {
100
- "Sid": "LambdaFriggFunctions",
101
- "Effect": "Allow",
102
- "Action": [
103
- "lambda:CreateFunction",
104
- "lambda:UpdateFunctionCode",
105
- "lambda:UpdateFunctionConfiguration",
106
- "lambda:DeleteFunction",
107
- "lambda:GetFunction",
108
- "lambda:ListFunctions",
109
- "lambda:PublishVersion",
110
- "lambda:CreateAlias",
111
- "lambda:UpdateAlias",
112
- "lambda:DeleteAlias",
113
- "lambda:GetAlias",
114
- "lambda:AddPermission",
115
- "lambda:RemovePermission",
116
- "lambda:GetPolicy",
117
- "lambda:PutProvisionedConcurrencyConfig",
118
- "lambda:DeleteProvisionedConcurrencyConfig",
119
- "lambda:PutConcurrency",
120
- "lambda:DeleteConcurrency",
121
- "lambda:TagResource",
122
- "lambda:UntagResource",
123
- "lambda:ListVersionsByFunction"
124
- ],
125
- "Resource": [
126
- "arn:aws:lambda:*:*:function:*frigg*"
127
- ]
128
- },
129
- {
130
- "Sid": "IAMRolesForFriggLambda",
131
- "Effect": "Allow",
132
- "Action": [
133
- "iam:CreateRole",
134
- "iam:DeleteRole",
135
- "iam:GetRole",
136
- "iam:PassRole",
137
- "iam:PutRolePolicy",
138
- "iam:DeleteRolePolicy",
139
- "iam:GetRolePolicy",
140
- "iam:AttachRolePolicy",
141
- "iam:DetachRolePolicy",
142
- "iam:TagRole",
143
- "iam:UntagRole"
144
- ],
145
- "Resource": [
146
- "arn:aws:iam::*:role/*frigg*",
147
- "arn:aws:iam::*:role/*frigg*LambdaRole*"
148
- ]
149
- },
150
- {
151
- "Sid": "IAMPolicyVersionPermissions",
152
- "Effect": "Allow",
153
- "Action": [
154
- "iam:ListPolicyVersions"
155
- ],
156
- "Resource": [
157
- "arn:aws:iam::*:policy/*"
158
- ]
159
- },
160
- {
161
- "Sid": "FriggMessagingServices",
162
- "Effect": "Allow",
163
- "Action": [
164
- "sqs:CreateQueue",
165
- "sqs:DeleteQueue",
166
- "sqs:GetQueueAttributes",
167
- "sqs:SetQueueAttributes",
168
- "sqs:GetQueueUrl",
169
- "sqs:TagQueue",
170
- "sqs:UntagQueue"
171
- ],
172
- "Resource": [
173
- "arn:aws:sqs:*:*:*frigg*",
174
- "arn:aws:sqs:*:*:internal-error-queue-*"
175
- ]
176
- },
177
- {
178
- "Sid": "FriggSNSTopics",
179
- "Effect": "Allow",
180
- "Action": [
181
- "sns:CreateTopic",
182
- "sns:DeleteTopic",
183
- "sns:GetTopicAttributes",
184
- "sns:SetTopicAttributes",
185
- "sns:Subscribe",
186
- "sns:Unsubscribe",
187
- "sns:TagResource",
188
- "sns:UntagResource"
189
- ],
190
- "Resource": [
191
- "arn:aws:sns:*:*:*frigg*"
192
- ]
193
- },
194
- {
195
- "Sid": "FriggMonitoringAndLogs",
196
- "Effect": "Allow",
197
- "Action": [
198
- "cloudwatch:PutMetricAlarm",
199
- "cloudwatch:DeleteAlarms",
200
- "cloudwatch:DescribeAlarms",
201
- "logs:CreateLogGroup",
202
- "logs:CreateLogStream",
203
- "logs:DeleteLogGroup",
204
- "logs:DescribeLogGroups",
205
- "logs:DescribeLogStreams",
206
- "logs:FilterLogEvents",
207
- "logs:PutLogEvents",
208
- "logs:PutRetentionPolicy"
209
- ],
210
- "Resource": [
211
- "arn:aws:logs:*:*:log-group:/aws/lambda/*frigg*",
212
- "arn:aws:logs:*:*:log-group:/aws/lambda/*frigg*:*",
213
- "arn:aws:cloudwatch:*:*:alarm:*frigg*"
214
- ]
215
- },
216
- {
217
- "Sid": "FriggAPIGateway",
218
- "Effect": "Allow",
219
- "Action": [
220
- "apigateway:POST",
221
- "apigateway:PUT",
222
- "apigateway:DELETE",
223
- "apigateway:GET",
224
- "apigateway:PATCH"
225
- ],
226
- "Resource": [
227
- "arn:aws:apigateway:*::/restapis",
228
- "arn:aws:apigateway:*::/restapis/*",
229
- "arn:aws:apigateway:*::/domainnames",
230
- "arn:aws:apigateway:*::/domainnames/*"
231
- ]
232
- }
233
- ]
234
- }
235
- ```
236
-
237
- ## Feature-Specific Permissions
238
-
239
- ### VPC Support
240
-
241
- Additional permissions needed when your app definition includes `vpc: { enable: true }`:
242
-
243
- ```json
244
- {
245
- "Version": "2012-10-17",
246
- "Statement": [
247
- {
248
- "Sid": "FriggVPCEndpointManagement",
249
- "Effect": "Allow",
250
- "Action": [
251
- "ec2:CreateVpcEndpoint",
252
- "ec2:DeleteVpcEndpoint",
253
- "ec2:DescribeVpcEndpoints",
254
- "ec2:ModifyVpcEndpoint",
255
- "ec2:CreateNatGateway",
256
- "ec2:DeleteNatGateway",
257
- "ec2:DescribeNatGateways",
258
- "ec2:AllocateAddress",
259
- "ec2:ReleaseAddress",
260
- "ec2:DescribeAddresses",
261
- "ec2:CreateRouteTable",
262
- "ec2:DeleteRouteTable",
263
- "ec2:DescribeRouteTables",
264
- "ec2:CreateRoute",
265
- "ec2:DeleteRoute",
266
- "ec2:AssociateRouteTable",
267
- "ec2:DisassociateRouteTable",
268
- "ec2:CreateSecurityGroup",
269
- "ec2:DeleteSecurityGroup",
270
- "ec2:AuthorizeSecurityGroupEgress",
271
- "ec2:AuthorizeSecurityGroupIngress",
272
- "ec2:RevokeSecurityGroupEgress",
273
- "ec2:RevokeSecurityGroupIngress"
274
- ],
275
- "Resource": "*",
276
- "Condition": {
277
- "StringLike": {
278
- "ec2:CreateAction": [
279
- "CreateVpcEndpoint",
280
- "CreateNatGateway",
281
- "CreateRouteTable",
282
- "CreateRoute",
283
- "CreateSecurityGroup"
284
- ]
285
- }
286
- }
287
- }
288
- ]
289
- }
290
- ```
291
-
292
- **What this enables:**
293
- - Creates NAT Gateway for Lambda internet access to external APIs (Salesforce, HubSpot, etc.)
294
- - Creates VPC endpoints for AWS services (S3, DynamoDB, KMS, SSM) to reduce NAT Gateway costs
295
- - Creates route tables and subnet associations for proper Lambda networking
296
- - Automatically configures your Lambda functions to run in your default VPC with full internet access
297
-
298
- ### KMS Support
299
-
300
- Additional permissions needed when your app definition includes `encryption: { useDefaultKMSForFieldLevelEncryption: true }`:
301
-
302
- ```json
303
- {
304
- "Version": "2012-10-17",
305
- "Statement": [
306
- {
307
- "Sid": "FriggKMSEncryptionRuntime",
308
- "Effect": "Allow",
309
- "Action": [
310
- "kms:GenerateDataKey",
311
- "kms:Decrypt"
312
- ],
313
- "Resource": [
314
- "arn:aws:kms:*:*:key/*"
315
- ],
316
- "Condition": {
317
- "StringEquals": {
318
- "kms:ViaService": [
319
- "lambda.*.amazonaws.com",
320
- "s3.*.amazonaws.com"
321
- ]
322
- }
323
- }
324
- }
325
- ]
326
- }
327
- ```
328
-
329
- **What this enables:**
330
- - Lambda functions can encrypt and decrypt data using your default KMS key
331
- - Automatic discovery and configuration of customer-managed KMS keys
332
- - Fallback to AWS-managed keys if no customer keys are available
333
-
334
- ### SSM Parameter Store Support
335
-
336
- Additional permissions needed when your app definition includes `ssm: { enable: true }`:
337
-
338
- ```json
339
- {
340
- "Version": "2012-10-17",
341
- "Statement": [
342
- {
343
- "Sid": "FriggSSMParameterAccess",
344
- "Effect": "Allow",
345
- "Action": [
346
- "ssm:GetParameter",
347
- "ssm:GetParameters",
348
- "ssm:GetParametersByPath"
349
- ],
350
- "Resource": [
351
- "arn:aws:ssm:*:*:parameter/*frigg*",
352
- "arn:aws:ssm:*:*:parameter/*frigg*/*"
353
- ]
354
- }
355
- ]
356
- }
357
- ```
358
-
359
- **What this enables:**
360
- - Lambda functions can retrieve configuration from SSM Parameter Store
361
- - Automatic configuration of AWS Parameters and Secrets Lambda Extension layer
362
- - Secure environment variable management through SSM
363
-
364
- ## Complete Policy Template
365
-
366
- For convenience, here's a single IAM policy that includes all permissions needed for full Frigg functionality:
367
-
368
- ```json
369
- {
370
- "Version": "2012-10-17",
371
- "Statement": [
372
- {
373
- "Sid": "FriggCorePermissions",
374
- "Effect": "Allow",
375
- "Action": [
376
- "sts:GetCallerIdentity",
377
- "cloudformation:*",
378
- "lambda:*",
379
- "apigateway:*",
380
- "logs:*",
381
- "sqs:*",
382
- "sns:*",
383
- "cloudwatch:*",
384
- "ec2:Describe*",
385
- "ec2:CreateVpcEndpoint",
386
- "ec2:DeleteVpcEndpoint",
387
- "ec2:ModifyVpcEndpoint",
388
- "kms:ListKeys",
389
- "kms:DescribeKey",
390
- "kms:GenerateDataKey",
391
- "kms:Decrypt",
392
- "ssm:GetParameter*"
393
- ],
394
- "Resource": "*"
395
- },
396
- {
397
- "Sid": "S3DeploymentBuckets",
398
- "Effect": "Allow",
399
- "Action": [
400
- "s3:*"
401
- ],
402
- "Resource": [
403
- "arn:aws:s3:::*serverless*",
404
- "arn:aws:s3:::*serverless*/*"
405
- ]
406
- },
407
- {
408
- "Sid": "IAMRoleManagement",
409
- "Effect": "Allow",
410
- "Action": [
411
- "iam:CreateRole",
412
- "iam:DeleteRole",
413
- "iam:GetRole",
414
- "iam:PassRole",
415
- "iam:PutRolePolicy",
416
- "iam:DeleteRolePolicy",
417
- "iam:GetRolePolicy",
418
- "iam:AttachRolePolicy",
419
- "iam:DetachRolePolicy",
420
- "iam:TagRole",
421
- "iam:UntagRole",
422
- "iam:ListPolicyVersions"
423
- ],
424
- "Resource": "arn:aws:iam::*:role/*"
425
- }
426
- ]
427
- }
428
- ```
429
-
430
- ## Security Improvements (Updated)
431
-
432
- ### Scoped Resource Permissions
433
-
434
- This policy has been updated to follow the principle of least privilege by scoping permissions to Frigg-specific resources:
435
-
436
- **Before (Overly Broad):**
437
- ```json
438
- "Resource": "*" // ❌ Too permissive
439
- ```
440
-
441
- **After (Frigg-Specific):**
442
- ```json
443
- "Resource": [
444
- "arn:aws:lambda:*:*:function:*frigg*" // ✅ Only functions containing "frigg"
445
- ]
446
- ```
447
-
448
- ### Key Security Enhancements
449
-
450
- 1. **CloudFormation Stacks**: Limited to stacks containing "frigg" in the name
451
- 2. **Lambda Functions**: Scoped to functions containing "frigg" in the name
452
- 3. **IAM Roles**: Restricted to roles containing "frigg" (including Lambda execution roles)
453
- 4. **SQS/SNS**: Limited to queues and topics containing "frigg" in the name
454
- 5. **Logs & Monitoring**: Scoped to Lambda log groups for Frigg functions and CloudWatch alarms containing "frigg"
455
- 6. **KMS**: Added ViaService condition to restrict usage to Lambda and S3 services only
456
- 7. **SSM Parameters**: Limited to parameter paths containing "frigg" in the path structure
457
-
458
- ### Naming Convention Requirements
459
-
460
- For these permissions to work properly, ensure your Frigg applications follow the naming convention of including "frigg" in resource names:
461
-
462
- ✅ **Good Examples:**
463
- - `my-frigg-app-dev` (CloudFormation stack)
464
- - `integration-frigg-service-auth` (Lambda function)
465
- - `customer-frigg-platform-prod-auth` (Lambda function)
466
- - `/my-frigg-app/prod/database-url` (SSM parameter)
467
- - `internal-error-queue-dev` (SQS queue - special pattern for error queues)
468
-
469
- ❌ **Won't Match:**
470
- - `my-integration-app-dev` (no "frigg" in name)
471
- - `customer-platform-prod` (no "frigg" in name)
472
-
473
- **Note:** The `internal-error-queue-*` pattern is specifically allowed for error handling queues.
474
-
475
- ## Security Best Practices
476
-
477
- ### Principle of Least Privilege
478
-
479
- For production deployments, consider creating separate policies for different environments:
480
-
481
- 1. **Development Policy** - Includes all permissions for full feature testing
482
- 2. **Production Policy** - Only includes permissions for features actually used in production
483
- 3. **CI/CD Policy** - Includes discovery and deployment permissions but restricts sensitive operations
484
-
485
- ### Resource-Specific Restrictions
486
-
487
- You can further restrict permissions by:
488
-
489
- ```json
490
- {
491
- "Resource": [
492
- "arn:aws:cloudformation:us-east-1:YOUR-ACCOUNT-ID:stack/your-app-*/*",
493
- "arn:aws:lambda:us-east-1:YOUR-ACCOUNT-ID:function:your-app-*"
494
- ]
495
- }
496
- ```
497
-
498
- ### Environment Variables for Discovery
499
-
500
- The discovery process sets these environment variables during build:
501
-
502
- - `AWS_DISCOVERY_VPC_ID` - Your default VPC ID
503
- - `AWS_DISCOVERY_SECURITY_GROUP_ID` - Default security group ID
504
- - `AWS_DISCOVERY_SUBNET_ID_1` - First private subnet ID (for Lambda functions)
505
- - `AWS_DISCOVERY_SUBNET_ID_2` - Second private subnet ID (for Lambda functions, or same as first if only one exists)
506
- - `AWS_DISCOVERY_PUBLIC_SUBNET_ID` - Public subnet ID (for NAT Gateway placement)
507
- - `AWS_DISCOVERY_ROUTE_TABLE_ID` - Private route table ID for VPC endpoints
508
- - `AWS_DISCOVERY_KMS_KEY_ID` - Default KMS key ARN
509
-
510
- ## Troubleshooting
511
-
512
- ### Common Permission Issues
513
-
514
- 1. **Discovery Fails** - Check that you have the discovery-time permissions
515
- 2. **VPC Endpoint Creation Fails** - Ensure you have `ec2:CreateVpcEndpoint` permission
516
- 3. **KMS Operations Fail** - Verify KMS key permissions and that the key exists
517
- 4. **SSM Parameter Access Fails** - Check SSM parameter path permissions
518
- 5. **IAM ListPolicyVersions Error** - If you see "User is not authorized to perform: iam:ListPolicyVersions", ensure your deployment user has this permission (added in recent versions)
519
- 6. **SQS SetQueueAttributes Error** - If you see errors for queues like "internal-error-queue-dev", ensure your IAM policy includes the pattern `arn:aws:sqs:*:*:internal-error-queue-*`
520
- 7. **CloudFormation ListStackResources Error** - If you see "User is not authorized to perform: cloudformation:ListStackResources", update your IAM stack with the latest template that includes this permission
521
-
522
- ### Fallback Behavior
523
-
524
- If AWS discovery fails during build, the framework will:
525
- - Log a warning message
526
- - Set fallback environment variables
527
- - Continue with deployment using safe default values
528
- - Not fail the build process
529
-
530
- ### Regional Considerations
531
-
532
- Ensure your IAM policy includes permissions for the AWS region where you're deploying:
533
- - Discovery permissions work across all regions (use `*` in resource ARNs)
534
- - Deployment permissions should match your target region
535
- - Some services like IAM are global, others are region-specific
536
-
537
- ## Using with CI/CD
538
-
539
- For automated deployments, ensure your CI/CD system has:
540
-
541
- 1. **AWS Credentials** configured (access key or IAM role)
542
- 2. **Region** set via `AWS_REGION` environment variable
543
- 3. **This IAM policy** attached to the deployment user/role
544
- 4. **Proper build order** - discovery runs before packaging
545
-
546
- Example GitHub Actions configuration:
547
-
548
- ```yaml
549
- - name: Configure AWS credentials
550
- uses: aws-actions/configure-aws-credentials@v1
551
- with:
552
- aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
553
- aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
554
- aws-region: us-east-1
555
-
556
- - name: Deploy Frigg App
557
- run: |
558
- frigg deploy
559
- ```
560
-
561
- This policy ensures your Frigg application can successfully discover AWS resources during build time and deploy all necessary infrastructure components during deployment.