@friggframework/devtools 2.0.0-next.3 → 2.0.0-next.30

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 (199) hide show
  1. package/frigg-cli/.eslintrc.js +141 -0
  2. package/frigg-cli/__tests__/jest.config.js +102 -0
  3. package/frigg-cli/__tests__/unit/commands/build.test.js +483 -0
  4. package/frigg-cli/__tests__/unit/commands/install.test.js +418 -0
  5. package/frigg-cli/__tests__/unit/commands/ui.test.js +592 -0
  6. package/frigg-cli/__tests__/utils/command-tester.js +170 -0
  7. package/frigg-cli/__tests__/utils/mock-factory.js +270 -0
  8. package/frigg-cli/__tests__/utils/test-fixtures.js +463 -0
  9. package/frigg-cli/__tests__/utils/test-setup.js +286 -0
  10. package/frigg-cli/build-command/index.js +54 -0
  11. package/frigg-cli/deploy-command/index.js +36 -0
  12. package/frigg-cli/generate-command/__tests__/generate-command.test.js +312 -0
  13. package/frigg-cli/generate-command/azure-generator.js +43 -0
  14. package/frigg-cli/generate-command/gcp-generator.js +47 -0
  15. package/frigg-cli/generate-command/index.js +332 -0
  16. package/frigg-cli/generate-command/terraform-generator.js +555 -0
  17. package/frigg-cli/generate-iam-command.js +115 -0
  18. package/frigg-cli/index.js +47 -1
  19. package/frigg-cli/index.test.js +1 -4
  20. package/frigg-cli/init-command/backend-first-handler.js +756 -0
  21. package/frigg-cli/init-command/index.js +93 -0
  22. package/frigg-cli/init-command/template-handler.js +143 -0
  23. package/frigg-cli/install-command/index.js +1 -4
  24. package/frigg-cli/package.json +51 -0
  25. package/frigg-cli/start-command/index.js +24 -4
  26. package/frigg-cli/test/init-command.test.js +180 -0
  27. package/frigg-cli/test/npm-registry.test.js +319 -0
  28. package/frigg-cli/ui-command/index.js +154 -0
  29. package/frigg-cli/utils/app-resolver.js +319 -0
  30. package/frigg-cli/utils/backend-path.js +16 -17
  31. package/frigg-cli/utils/npm-registry.js +167 -0
  32. package/frigg-cli/utils/process-manager.js +199 -0
  33. package/frigg-cli/utils/repo-detection.js +405 -0
  34. package/infrastructure/AWS-DISCOVERY-TROUBLESHOOTING.md +245 -0
  35. package/infrastructure/AWS-IAM-CREDENTIAL-NEEDS.md +596 -0
  36. package/infrastructure/DEPLOYMENT-INSTRUCTIONS.md +268 -0
  37. package/infrastructure/GENERATE-IAM-DOCS.md +253 -0
  38. package/infrastructure/IAM-POLICY-TEMPLATES.md +176 -0
  39. package/infrastructure/README-TESTING.md +332 -0
  40. package/infrastructure/README.md +421 -0
  41. package/infrastructure/WEBSOCKET-CONFIGURATION.md +105 -0
  42. package/infrastructure/__tests__/fixtures/mock-aws-resources.js +391 -0
  43. package/infrastructure/__tests__/helpers/test-utils.js +277 -0
  44. package/infrastructure/aws-discovery.js +568 -0
  45. package/infrastructure/aws-discovery.test.js +373 -0
  46. package/infrastructure/build-time-discovery.js +206 -0
  47. package/infrastructure/build-time-discovery.test.js +375 -0
  48. package/infrastructure/create-frigg-infrastructure.js +3 -5
  49. package/infrastructure/frigg-deployment-iam-stack.yaml +379 -0
  50. package/infrastructure/iam-generator.js +687 -0
  51. package/infrastructure/iam-generator.test.js +169 -0
  52. package/infrastructure/iam-policy-basic.json +212 -0
  53. package/infrastructure/iam-policy-full.json +282 -0
  54. package/infrastructure/integration.test.js +383 -0
  55. package/infrastructure/run-discovery.js +110 -0
  56. package/infrastructure/serverless-template.js +923 -113
  57. package/infrastructure/serverless-template.test.js +541 -0
  58. package/management-ui/.eslintrc.js +22 -0
  59. package/management-ui/README.md +203 -0
  60. package/management-ui/components.json +21 -0
  61. package/management-ui/docs/phase2-integration-guide.md +320 -0
  62. package/management-ui/index.html +13 -0
  63. package/management-ui/package-lock.json +16517 -0
  64. package/management-ui/package.json +76 -0
  65. package/management-ui/packages/devtools/frigg-cli/ui-command/index.js +302 -0
  66. package/management-ui/postcss.config.js +6 -0
  67. package/management-ui/server/api/backend.js +256 -0
  68. package/management-ui/server/api/cli.js +315 -0
  69. package/management-ui/server/api/codegen.js +663 -0
  70. package/management-ui/server/api/connections.js +857 -0
  71. package/management-ui/server/api/discovery.js +185 -0
  72. package/management-ui/server/api/environment/index.js +1 -0
  73. package/management-ui/server/api/environment/router.js +378 -0
  74. package/management-ui/server/api/environment.js +328 -0
  75. package/management-ui/server/api/integrations.js +876 -0
  76. package/management-ui/server/api/logs.js +248 -0
  77. package/management-ui/server/api/monitoring.js +282 -0
  78. package/management-ui/server/api/open-ide.js +31 -0
  79. package/management-ui/server/api/project.js +1029 -0
  80. package/management-ui/server/api/users/sessions.js +371 -0
  81. package/management-ui/server/api/users/simulation.js +254 -0
  82. package/management-ui/server/api/users.js +362 -0
  83. package/management-ui/server/api-contract.md +275 -0
  84. package/management-ui/server/index.js +873 -0
  85. package/management-ui/server/middleware/errorHandler.js +93 -0
  86. package/management-ui/server/middleware/security.js +32 -0
  87. package/management-ui/server/processManager.js +296 -0
  88. package/management-ui/server/server.js +346 -0
  89. package/management-ui/server/services/aws-monitor.js +413 -0
  90. package/management-ui/server/services/npm-registry.js +347 -0
  91. package/management-ui/server/services/template-engine.js +538 -0
  92. package/management-ui/server/utils/cliIntegration.js +220 -0
  93. package/management-ui/server/utils/environment/auditLogger.js +471 -0
  94. package/management-ui/server/utils/environment/awsParameterStore.js +264 -0
  95. package/management-ui/server/utils/environment/encryption.js +278 -0
  96. package/management-ui/server/utils/environment/envFileManager.js +286 -0
  97. package/management-ui/server/utils/import-commonjs.js +28 -0
  98. package/management-ui/server/utils/response.js +83 -0
  99. package/management-ui/server/websocket/handler.js +325 -0
  100. package/management-ui/src/App.jsx +109 -0
  101. package/management-ui/src/assets/FriggLogo.svg +1 -0
  102. package/management-ui/src/components/AppRouter.jsx +65 -0
  103. package/management-ui/src/components/Button.jsx +70 -0
  104. package/management-ui/src/components/Card.jsx +97 -0
  105. package/management-ui/src/components/EnvironmentCompare.jsx +400 -0
  106. package/management-ui/src/components/EnvironmentEditor.jsx +372 -0
  107. package/management-ui/src/components/EnvironmentImportExport.jsx +469 -0
  108. package/management-ui/src/components/EnvironmentSchema.jsx +491 -0
  109. package/management-ui/src/components/EnvironmentSecurity.jsx +463 -0
  110. package/management-ui/src/components/ErrorBoundary.jsx +73 -0
  111. package/management-ui/src/components/IntegrationCard.jsx +481 -0
  112. package/management-ui/src/components/IntegrationCardEnhanced.jsx +770 -0
  113. package/management-ui/src/components/IntegrationExplorer.jsx +379 -0
  114. package/management-ui/src/components/IntegrationStatus.jsx +336 -0
  115. package/management-ui/src/components/Layout.jsx +716 -0
  116. package/management-ui/src/components/LoadingSpinner.jsx +113 -0
  117. package/management-ui/src/components/RepositoryPicker.jsx +248 -0
  118. package/management-ui/src/components/SessionMonitor.jsx +350 -0
  119. package/management-ui/src/components/StatusBadge.jsx +208 -0
  120. package/management-ui/src/components/UserContextSwitcher.jsx +212 -0
  121. package/management-ui/src/components/UserSimulation.jsx +327 -0
  122. package/management-ui/src/components/Welcome.jsx +434 -0
  123. package/management-ui/src/components/codegen/APIEndpointGenerator.jsx +637 -0
  124. package/management-ui/src/components/codegen/APIModuleSelector.jsx +227 -0
  125. package/management-ui/src/components/codegen/CodeGenerationWizard.jsx +247 -0
  126. package/management-ui/src/components/codegen/CodePreviewEditor.jsx +316 -0
  127. package/management-ui/src/components/codegen/DynamicModuleForm.jsx +271 -0
  128. package/management-ui/src/components/codegen/FormBuilder.jsx +737 -0
  129. package/management-ui/src/components/codegen/IntegrationGenerator.jsx +855 -0
  130. package/management-ui/src/components/codegen/ProjectScaffoldWizard.jsx +797 -0
  131. package/management-ui/src/components/codegen/SchemaBuilder.jsx +303 -0
  132. package/management-ui/src/components/codegen/TemplateSelector.jsx +586 -0
  133. package/management-ui/src/components/codegen/index.js +10 -0
  134. package/management-ui/src/components/connections/ConnectionConfigForm.jsx +362 -0
  135. package/management-ui/src/components/connections/ConnectionHealthMonitor.jsx +182 -0
  136. package/management-ui/src/components/connections/ConnectionTester.jsx +200 -0
  137. package/management-ui/src/components/connections/EntityRelationshipMapper.jsx +292 -0
  138. package/management-ui/src/components/connections/OAuthFlow.jsx +204 -0
  139. package/management-ui/src/components/connections/index.js +5 -0
  140. package/management-ui/src/components/index.js +21 -0
  141. package/management-ui/src/components/monitoring/APIGatewayMetrics.jsx +222 -0
  142. package/management-ui/src/components/monitoring/LambdaMetrics.jsx +169 -0
  143. package/management-ui/src/components/monitoring/MetricsChart.jsx +197 -0
  144. package/management-ui/src/components/monitoring/MonitoringDashboard.jsx +393 -0
  145. package/management-ui/src/components/monitoring/SQSMetrics.jsx +246 -0
  146. package/management-ui/src/components/monitoring/index.js +6 -0
  147. package/management-ui/src/components/monitoring/monitoring.css +218 -0
  148. package/management-ui/src/components/theme-provider.jsx +52 -0
  149. package/management-ui/src/components/theme-toggle.jsx +39 -0
  150. package/management-ui/src/components/ui/badge.tsx +36 -0
  151. package/management-ui/src/components/ui/button.test.jsx +56 -0
  152. package/management-ui/src/components/ui/button.tsx +57 -0
  153. package/management-ui/src/components/ui/card.tsx +76 -0
  154. package/management-ui/src/components/ui/dropdown-menu.tsx +199 -0
  155. package/management-ui/src/components/ui/select.tsx +157 -0
  156. package/management-ui/src/components/ui/skeleton.jsx +15 -0
  157. package/management-ui/src/hooks/useFrigg.jsx +601 -0
  158. package/management-ui/src/hooks/useSocket.jsx +58 -0
  159. package/management-ui/src/index.css +193 -0
  160. package/management-ui/src/lib/utils.ts +6 -0
  161. package/management-ui/src/main.jsx +10 -0
  162. package/management-ui/src/pages/CodeGeneration.jsx +14 -0
  163. package/management-ui/src/pages/Connections.jsx +252 -0
  164. package/management-ui/src/pages/ConnectionsEnhanced.jsx +633 -0
  165. package/management-ui/src/pages/Dashboard.jsx +311 -0
  166. package/management-ui/src/pages/Environment.jsx +314 -0
  167. package/management-ui/src/pages/IntegrationConfigure.jsx +669 -0
  168. package/management-ui/src/pages/IntegrationDiscovery.jsx +567 -0
  169. package/management-ui/src/pages/IntegrationTest.jsx +742 -0
  170. package/management-ui/src/pages/Integrations.jsx +253 -0
  171. package/management-ui/src/pages/Monitoring.jsx +17 -0
  172. package/management-ui/src/pages/Simulation.jsx +155 -0
  173. package/management-ui/src/pages/Users.jsx +492 -0
  174. package/management-ui/src/services/api.js +41 -0
  175. package/management-ui/src/services/apiModuleService.js +193 -0
  176. package/management-ui/src/services/websocket-handlers.js +120 -0
  177. package/management-ui/src/test/api/project.test.js +273 -0
  178. package/management-ui/src/test/components/Welcome.test.jsx +378 -0
  179. package/management-ui/src/test/mocks/server.js +178 -0
  180. package/management-ui/src/test/setup.js +61 -0
  181. package/management-ui/src/test/utils/test-utils.jsx +134 -0
  182. package/management-ui/src/utils/repository.js +98 -0
  183. package/management-ui/src/utils/repository.test.js +118 -0
  184. package/management-ui/src/workflows/phase2-integration-workflows.js +884 -0
  185. package/management-ui/tailwind.config.js +63 -0
  186. package/management-ui/tsconfig.json +37 -0
  187. package/management-ui/tsconfig.node.json +10 -0
  188. package/management-ui/vite.config.js +26 -0
  189. package/management-ui/vitest.config.js +38 -0
  190. package/package.json +16 -9
  191. package/infrastructure/app-handler-helpers.js +0 -57
  192. package/infrastructure/backend-utils.js +0 -90
  193. package/infrastructure/routers/auth.js +0 -26
  194. package/infrastructure/routers/integration-defined-routers.js +0 -37
  195. package/infrastructure/routers/middleware/loadUser.js +0 -15
  196. package/infrastructure/routers/middleware/requireLoggedInUser.js +0 -12
  197. package/infrastructure/routers/user.js +0 -41
  198. package/infrastructure/routers/websocket.js +0 -55
  199. package/infrastructure/workers/integration-defined-workers.js +0 -24
@@ -0,0 +1,596 @@
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
+ "ec2:DescribeNatGateways",
32
+ "ec2:DescribeAddresses",
33
+ "kms:ListKeys",
34
+ "kms:DescribeKey"
35
+ ],
36
+ "Resource": "*"
37
+ }
38
+ ]
39
+ }
40
+ ```
41
+
42
+ ### What Each Permission Does:
43
+ - **`sts:GetCallerIdentity`** - Gets your AWS account ID for KMS key ARN construction
44
+ - **`ec2:DescribeVpcs`** - Finds your default VPC or first available VPC
45
+ - **`ec2:DescribeSubnets`** - Identifies private subnets within your VPC
46
+ - **`ec2:DescribeSecurityGroups`** - Locates default security group or Frigg-specific security group
47
+ - **`ec2:DescribeRouteTables`** - Determines which subnets are private (no direct internet gateway route)
48
+ - **`ec2:DescribeNatGateways`** - Finds existing NAT Gateways to reuse (prevents duplicate resource creation)
49
+ - **`ec2:DescribeAddresses`** - Finds available Elastic IPs to reuse (prevents allocation conflicts)
50
+ - **`kms:ListKeys`** - Lists available KMS keys in your account
51
+ - **`kms:DescribeKey`** - Gets details about KMS keys to find customer-managed keys
52
+
53
+ ## Core Deployment Permissions
54
+
55
+ Required for basic Frigg application deployment:
56
+
57
+ ```json
58
+ {
59
+ "Version": "2012-10-17",
60
+ "Statement": [
61
+ {
62
+ "Sid": "CloudFormationFriggStacks",
63
+ "Effect": "Allow",
64
+ "Action": [
65
+ "cloudformation:CreateStack",
66
+ "cloudformation:UpdateStack",
67
+ "cloudformation:DeleteStack",
68
+ "cloudformation:DescribeStacks",
69
+ "cloudformation:DescribeStackEvents",
70
+ "cloudformation:DescribeStackResources",
71
+ "cloudformation:DescribeStackResource",
72
+ "cloudformation:ListStackResources",
73
+ "cloudformation:GetTemplate",
74
+ "cloudformation:ValidateTemplate",
75
+ "cloudformation:DescribeChangeSet",
76
+ "cloudformation:CreateChangeSet",
77
+ "cloudformation:DeleteChangeSet",
78
+ "cloudformation:ExecuteChangeSet"
79
+ ],
80
+ "Resource": [
81
+ "arn:aws:cloudformation:*:*:stack/*frigg*/*"
82
+ ]
83
+ },
84
+ {
85
+ "Sid": "S3DeploymentBucket",
86
+ "Effect": "Allow",
87
+ "Action": [
88
+ "s3:CreateBucket",
89
+ "s3:PutObject",
90
+ "s3:GetObject",
91
+ "s3:DeleteObject",
92
+ "s3:PutBucketPolicy",
93
+ "s3:PutBucketVersioning",
94
+ "s3:PutBucketPublicAccessBlock",
95
+ "s3:GetBucketLocation",
96
+ "s3:ListBucket",
97
+ "s3:PutBucketTagging",
98
+ "s3:GetBucketTagging"
99
+ ],
100
+ "Resource": [
101
+ "arn:aws:s3:::*serverless*",
102
+ "arn:aws:s3:::*serverless*/*"
103
+ ]
104
+ },
105
+ {
106
+ "Sid": "LambdaFriggFunctions",
107
+ "Effect": "Allow",
108
+ "Action": [
109
+ "lambda:CreateFunction",
110
+ "lambda:UpdateFunctionCode",
111
+ "lambda:UpdateFunctionConfiguration",
112
+ "lambda:DeleteFunction",
113
+ "lambda:GetFunction",
114
+ "lambda:ListFunctions",
115
+ "lambda:PublishVersion",
116
+ "lambda:CreateAlias",
117
+ "lambda:UpdateAlias",
118
+ "lambda:DeleteAlias",
119
+ "lambda:GetAlias",
120
+ "lambda:AddPermission",
121
+ "lambda:RemovePermission",
122
+ "lambda:GetPolicy",
123
+ "lambda:PutProvisionedConcurrencyConfig",
124
+ "lambda:DeleteProvisionedConcurrencyConfig",
125
+ "lambda:PutConcurrency",
126
+ "lambda:DeleteConcurrency",
127
+ "lambda:TagResource",
128
+ "lambda:UntagResource",
129
+ "lambda:ListVersionsByFunction"
130
+ ],
131
+ "Resource": [
132
+ "arn:aws:lambda:*:*:function:*frigg*"
133
+ ]
134
+ },
135
+ {
136
+ "Sid": "FriggLambdaEventSourceMapping",
137
+ "Effect": "Allow",
138
+ "Action": [
139
+ "lambda:CreateEventSourceMapping",
140
+ "lambda:DeleteEventSourceMapping",
141
+ "lambda:GetEventSourceMapping",
142
+ "lambda:UpdateEventSourceMapping",
143
+ "lambda:ListEventSourceMappings"
144
+ ],
145
+ "Resource": [
146
+ "arn:aws:lambda:*:*:event-source-mapping:*"
147
+ ]
148
+ },
149
+ {
150
+ "Sid": "IAMRolesForFriggLambda",
151
+ "Effect": "Allow",
152
+ "Action": [
153
+ "iam:CreateRole",
154
+ "iam:DeleteRole",
155
+ "iam:GetRole",
156
+ "iam:PassRole",
157
+ "iam:PutRolePolicy",
158
+ "iam:DeleteRolePolicy",
159
+ "iam:GetRolePolicy",
160
+ "iam:AttachRolePolicy",
161
+ "iam:DetachRolePolicy",
162
+ "iam:TagRole",
163
+ "iam:UntagRole"
164
+ ],
165
+ "Resource": [
166
+ "arn:aws:iam::*:role/*frigg*",
167
+ "arn:aws:iam::*:role/*frigg*LambdaRole*"
168
+ ]
169
+ },
170
+ {
171
+ "Sid": "IAMPolicyVersionPermissions",
172
+ "Effect": "Allow",
173
+ "Action": [
174
+ "iam:ListPolicyVersions"
175
+ ],
176
+ "Resource": [
177
+ "arn:aws:iam::*:policy/*"
178
+ ]
179
+ },
180
+ {
181
+ "Sid": "FriggMessagingServices",
182
+ "Effect": "Allow",
183
+ "Action": [
184
+ "sqs:CreateQueue",
185
+ "sqs:DeleteQueue",
186
+ "sqs:GetQueueAttributes",
187
+ "sqs:SetQueueAttributes",
188
+ "sqs:GetQueueUrl",
189
+ "sqs:TagQueue",
190
+ "sqs:UntagQueue"
191
+ ],
192
+ "Resource": [
193
+ "arn:aws:sqs:*:*:*frigg*",
194
+ "arn:aws:sqs:*:*:internal-error-queue-*"
195
+ ]
196
+ },
197
+ {
198
+ "Sid": "FriggSNSTopics",
199
+ "Effect": "Allow",
200
+ "Action": [
201
+ "sns:CreateTopic",
202
+ "sns:DeleteTopic",
203
+ "sns:GetTopicAttributes",
204
+ "sns:SetTopicAttributes",
205
+ "sns:Subscribe",
206
+ "sns:Unsubscribe",
207
+ "sns:TagResource",
208
+ "sns:UntagResource"
209
+ ],
210
+ "Resource": [
211
+ "arn:aws:sns:*:*:*frigg*"
212
+ ]
213
+ },
214
+ {
215
+ "Sid": "FriggMonitoringAndLogs",
216
+ "Effect": "Allow",
217
+ "Action": [
218
+ "cloudwatch:PutMetricAlarm",
219
+ "cloudwatch:DeleteAlarms",
220
+ "cloudwatch:DescribeAlarms",
221
+ "logs:CreateLogGroup",
222
+ "logs:CreateLogStream",
223
+ "logs:DeleteLogGroup",
224
+ "logs:DescribeLogGroups",
225
+ "logs:DescribeLogStreams",
226
+ "logs:FilterLogEvents",
227
+ "logs:PutLogEvents",
228
+ "logs:PutRetentionPolicy"
229
+ ],
230
+ "Resource": [
231
+ "arn:aws:logs:*:*:log-group:/aws/lambda/*frigg*",
232
+ "arn:aws:logs:*:*:log-group:/aws/lambda/*frigg*:*",
233
+ "arn:aws:cloudwatch:*:*:alarm:*frigg*"
234
+ ]
235
+ },
236
+ {
237
+ "Sid": "FriggAPIGateway",
238
+ "Effect": "Allow",
239
+ "Action": [
240
+ "apigateway:POST",
241
+ "apigateway:PUT",
242
+ "apigateway:DELETE",
243
+ "apigateway:GET",
244
+ "apigateway:PATCH"
245
+ ],
246
+ "Resource": [
247
+ "arn:aws:apigateway:*::/restapis",
248
+ "arn:aws:apigateway:*::/restapis/*",
249
+ "arn:aws:apigateway:*::/domainnames",
250
+ "arn:aws:apigateway:*::/domainnames/*"
251
+ ]
252
+ }
253
+ ]
254
+ }
255
+ ```
256
+
257
+ **What the Lambda permissions enable:**
258
+ - **Function Management**: Create, update, delete, and configure Lambda functions
259
+ - **Version & Alias Management**: Publish new versions and manage aliases for deployments
260
+ - **Permission Management**: Add/remove function permissions for API Gateway and other services
261
+ - **Concurrency Management**: Configure provisioned and reserved concurrency
262
+ - **EventSourceMapping Management**: Connect Lambda functions to event sources like SQS, SNS, Kinesis, and DynamoDB streams. These permissions are crucial for:
263
+ - Creating mappings between SQS queues and Lambda functions
264
+ - Managing event-driven architectures
265
+ - Handling queue-based processing (e.g., HubSpot integration queues)
266
+ - Cleaning up event source mappings during stack deletion
267
+
268
+ ## Feature-Specific Permissions
269
+
270
+ ### VPC Support
271
+
272
+ Additional permissions needed when your app definition includes `vpc: { enable: true }`:
273
+
274
+ ```json
275
+ {
276
+ "Version": "2012-10-17",
277
+ "Statement": [
278
+ {
279
+ "Sid": "FriggVPCEndpointManagement",
280
+ "Effect": "Allow",
281
+ "Action": [
282
+ "ec2:CreateVpcEndpoint",
283
+ "ec2:DeleteVpcEndpoint",
284
+ "ec2:DescribeVpcEndpoints",
285
+ "ec2:ModifyVpcEndpoint",
286
+ "ec2:CreateNatGateway",
287
+ "ec2:DeleteNatGateway",
288
+ "ec2:DescribeNatGateways",
289
+ "ec2:AllocateAddress",
290
+ "ec2:ReleaseAddress",
291
+ "ec2:DescribeAddresses",
292
+ "ec2:CreateRouteTable",
293
+ "ec2:DeleteRouteTable",
294
+ "ec2:DescribeRouteTables",
295
+ "ec2:CreateRoute",
296
+ "ec2:DeleteRoute",
297
+ "ec2:AssociateRouteTable",
298
+ "ec2:DisassociateRouteTable",
299
+ "ec2:CreateSecurityGroup",
300
+ "ec2:DeleteSecurityGroup",
301
+ "ec2:AuthorizeSecurityGroupEgress",
302
+ "ec2:AuthorizeSecurityGroupIngress",
303
+ "ec2:RevokeSecurityGroupEgress",
304
+ "ec2:RevokeSecurityGroupIngress"
305
+ ],
306
+ "Resource": "*",
307
+ "Condition": {
308
+ "StringLike": {
309
+ "ec2:CreateAction": [
310
+ "CreateVpcEndpoint",
311
+ "CreateNatGateway",
312
+ "CreateRouteTable",
313
+ "CreateRoute",
314
+ "CreateSecurityGroup"
315
+ ]
316
+ }
317
+ }
318
+ }
319
+ ]
320
+ }
321
+ ```
322
+
323
+ **What this enables:**
324
+ - Creates NAT Gateway for Lambda internet access to external APIs (Salesforce, HubSpot, etc.)
325
+ - Creates VPC endpoints for AWS services (S3, DynamoDB, KMS, SSM) to reduce NAT Gateway costs
326
+ - Creates route tables and subnet associations for proper Lambda networking
327
+ - Automatically configures your Lambda functions to run in your default VPC with full internet access
328
+
329
+ ### KMS Support
330
+
331
+ Additional permissions needed when your app definition includes `encryption: { useDefaultKMSForFieldLevelEncryption: true }`:
332
+
333
+ ```json
334
+ {
335
+ "Version": "2012-10-17",
336
+ "Statement": [
337
+ {
338
+ "Sid": "FriggKMSEncryptionRuntime",
339
+ "Effect": "Allow",
340
+ "Action": [
341
+ "kms:GenerateDataKey",
342
+ "kms:Decrypt"
343
+ ],
344
+ "Resource": [
345
+ "arn:aws:kms:*:*:key/*"
346
+ ],
347
+ "Condition": {
348
+ "StringEquals": {
349
+ "kms:ViaService": [
350
+ "lambda.*.amazonaws.com",
351
+ "s3.*.amazonaws.com"
352
+ ]
353
+ }
354
+ }
355
+ }
356
+ ]
357
+ }
358
+ ```
359
+
360
+ **What this enables:**
361
+ - Lambda functions can encrypt and decrypt data using your default KMS key
362
+ - Automatic discovery and configuration of customer-managed KMS keys
363
+ - Fallback to AWS-managed keys if no customer keys are available
364
+
365
+ ### SSM Parameter Store Support
366
+
367
+ Additional permissions needed when your app definition includes `ssm: { enable: true }`:
368
+
369
+ ```json
370
+ {
371
+ "Version": "2012-10-17",
372
+ "Statement": [
373
+ {
374
+ "Sid": "FriggSSMParameterAccess",
375
+ "Effect": "Allow",
376
+ "Action": [
377
+ "ssm:GetParameter",
378
+ "ssm:GetParameters",
379
+ "ssm:GetParametersByPath"
380
+ ],
381
+ "Resource": [
382
+ "arn:aws:ssm:*:*:parameter/*frigg*",
383
+ "arn:aws:ssm:*:*:parameter/*frigg*/*"
384
+ ]
385
+ }
386
+ ]
387
+ }
388
+ ```
389
+
390
+ **What this enables:**
391
+ - Lambda functions can retrieve configuration from SSM Parameter Store
392
+ - Automatic configuration of AWS Parameters and Secrets Lambda Extension layer
393
+ - Secure environment variable management through SSM
394
+
395
+ ## Complete Policy Template
396
+
397
+ For convenience, here's a single IAM policy that includes all permissions needed for full Frigg functionality:
398
+
399
+ ```json
400
+ {
401
+ "Version": "2012-10-17",
402
+ "Statement": [
403
+ {
404
+ "Sid": "FriggCorePermissions",
405
+ "Effect": "Allow",
406
+ "Action": [
407
+ "sts:GetCallerIdentity",
408
+ "cloudformation:*",
409
+ "lambda:*",
410
+ "apigateway:*",
411
+ "logs:*",
412
+ "sqs:*",
413
+ "sns:*",
414
+ "cloudwatch:*",
415
+ "ec2:Describe*",
416
+ "ec2:CreateVpcEndpoint",
417
+ "ec2:DeleteVpcEndpoint",
418
+ "ec2:ModifyVpcEndpoint",
419
+ "kms:ListKeys",
420
+ "kms:DescribeKey",
421
+ "kms:GenerateDataKey",
422
+ "kms:Decrypt",
423
+ "ssm:GetParameter*"
424
+ ],
425
+ "Resource": "*"
426
+ },
427
+ {
428
+ "Sid": "S3DeploymentBuckets",
429
+ "Effect": "Allow",
430
+ "Action": [
431
+ "s3:*"
432
+ ],
433
+ "Resource": [
434
+ "arn:aws:s3:::*serverless*",
435
+ "arn:aws:s3:::*serverless*/*"
436
+ ]
437
+ },
438
+ {
439
+ "Sid": "IAMRoleManagement",
440
+ "Effect": "Allow",
441
+ "Action": [
442
+ "iam:CreateRole",
443
+ "iam:DeleteRole",
444
+ "iam:GetRole",
445
+ "iam:PassRole",
446
+ "iam:PutRolePolicy",
447
+ "iam:DeleteRolePolicy",
448
+ "iam:GetRolePolicy",
449
+ "iam:AttachRolePolicy",
450
+ "iam:DetachRolePolicy",
451
+ "iam:TagRole",
452
+ "iam:UntagRole",
453
+ "iam:ListPolicyVersions"
454
+ ],
455
+ "Resource": "arn:aws:iam::*:role/*"
456
+ }
457
+ ]
458
+ }
459
+ ```
460
+
461
+ ## Security Improvements (Updated)
462
+
463
+ ### Scoped Resource Permissions
464
+
465
+ This policy has been updated to follow the principle of least privilege by scoping permissions to Frigg-specific resources:
466
+
467
+ **Before (Overly Broad):**
468
+ ```json
469
+ "Resource": "*" // ❌ Too permissive
470
+ ```
471
+
472
+ **After (Frigg-Specific):**
473
+ ```json
474
+ "Resource": [
475
+ "arn:aws:lambda:*:*:function:*frigg*" // ✅ Only functions containing "frigg"
476
+ ]
477
+ ```
478
+
479
+ ### Key Security Enhancements
480
+
481
+ 1. **CloudFormation Stacks**: Limited to stacks containing "frigg" in the name
482
+ 2. **Lambda Functions**: Scoped to functions containing "frigg" in the name
483
+ 3. **IAM Roles**: Restricted to roles containing "frigg" (including Lambda execution roles)
484
+ 4. **SQS/SNS**: Limited to queues and topics containing "frigg" in the name
485
+ 5. **Logs & Monitoring**: Scoped to Lambda log groups for Frigg functions and CloudWatch alarms containing "frigg"
486
+ 6. **KMS**: Added ViaService condition to restrict usage to Lambda and S3 services only
487
+ 7. **SSM Parameters**: Limited to parameter paths containing "frigg" in the path structure
488
+
489
+ ### Naming Convention Requirements
490
+
491
+ For these permissions to work properly, ensure your Frigg applications follow the naming convention of including "frigg" in resource names:
492
+
493
+ ✅ **Good Examples:**
494
+ - `my-frigg-app-dev` (CloudFormation stack)
495
+ - `integration-frigg-service-auth` (Lambda function)
496
+ - `customer-frigg-platform-prod-auth` (Lambda function)
497
+ - `/my-frigg-app/prod/database-url` (SSM parameter)
498
+ - `internal-error-queue-dev` (SQS queue - special pattern for error queues)
499
+
500
+ ❌ **Won't Match:**
501
+ - `my-integration-app-dev` (no "frigg" in name)
502
+ - `customer-platform-prod` (no "frigg" in name)
503
+
504
+ **Note:** The `internal-error-queue-*` pattern is specifically allowed for error handling queues.
505
+
506
+ ## Security Best Practices
507
+
508
+ ### Principle of Least Privilege
509
+
510
+ For production deployments, consider creating separate policies for different environments:
511
+
512
+ 1. **Development Policy** - Includes all permissions for full feature testing
513
+ 2. **Production Policy** - Only includes permissions for features actually used in production
514
+ 3. **CI/CD Policy** - Includes discovery and deployment permissions but restricts sensitive operations
515
+
516
+ ### Resource-Specific Restrictions
517
+
518
+ You can further restrict permissions by:
519
+
520
+ ```json
521
+ {
522
+ "Resource": [
523
+ "arn:aws:cloudformation:us-east-1:YOUR-ACCOUNT-ID:stack/your-app-*/*",
524
+ "arn:aws:lambda:us-east-1:YOUR-ACCOUNT-ID:function:your-app-*"
525
+ ]
526
+ }
527
+ ```
528
+
529
+ ### Environment Variables for Discovery
530
+
531
+ The discovery process sets these environment variables during build:
532
+
533
+ - `AWS_DISCOVERY_VPC_ID` - Your default VPC ID
534
+ - `AWS_DISCOVERY_SECURITY_GROUP_ID` - Default security group ID
535
+ - `AWS_DISCOVERY_SUBNET_ID_1` - First private subnet ID (for Lambda functions)
536
+ - `AWS_DISCOVERY_SUBNET_ID_2` - Second private subnet ID (for Lambda functions, or same as first if only one exists)
537
+ - `AWS_DISCOVERY_PUBLIC_SUBNET_ID` - Public subnet ID (for NAT Gateway placement)
538
+ - `AWS_DISCOVERY_ROUTE_TABLE_ID` - Private route table ID for VPC endpoints
539
+ - `AWS_DISCOVERY_KMS_KEY_ID` - Default KMS key ARN
540
+ - `AWS_DISCOVERY_NAT_GATEWAY_ID` - Existing NAT Gateway ID (if found)
541
+ - `AWS_DISCOVERY_ELASTIC_IP_ALLOCATION_ID` - Existing Elastic IP allocation ID (if found)
542
+
543
+ ## Troubleshooting
544
+
545
+ ### Common Permission Issues
546
+
547
+ 1. **Discovery Fails** - Check that you have the discovery-time permissions
548
+ 2. **VPC Endpoint Creation Fails** - Ensure you have `ec2:CreateVpcEndpoint` permission
549
+ 3. **KMS Operations Fail** - Verify KMS key permissions and that the key exists
550
+ 4. **SSM Parameter Access Fails** - Check SSM parameter path permissions
551
+ 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)
552
+ 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-*`
553
+ 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
554
+ 8. **Elastic IP Already Associated Error** - If you see "Elastic IP address is already associated", the discovery process will now find and reuse existing NAT Gateways and EIPs to prevent conflicts
555
+ 9. **Lambda EventSourceMapping Error** - If you see "User is not authorized to perform: lambda:DeleteEventSourceMapping", update your IAM stack with the latest template that includes EventSourceMapping permissions
556
+
557
+ ### Fallback Behavior
558
+
559
+ If AWS discovery fails during build, the framework will:
560
+ - Log a warning message
561
+ - Set fallback environment variables
562
+ - Continue with deployment using safe default values
563
+ - Not fail the build process
564
+
565
+ ### Regional Considerations
566
+
567
+ Ensure your IAM policy includes permissions for the AWS region where you're deploying:
568
+ - Discovery permissions work across all regions (use `*` in resource ARNs)
569
+ - Deployment permissions should match your target region
570
+ - Some services like IAM are global, others are region-specific
571
+
572
+ ## Using with CI/CD
573
+
574
+ For automated deployments, ensure your CI/CD system has:
575
+
576
+ 1. **AWS Credentials** configured (access key or IAM role)
577
+ 2. **Region** set via `AWS_REGION` environment variable
578
+ 3. **This IAM policy** attached to the deployment user/role
579
+ 4. **Proper build order** - discovery runs before packaging
580
+
581
+ Example GitHub Actions configuration:
582
+
583
+ ```yaml
584
+ - name: Configure AWS credentials
585
+ uses: aws-actions/configure-aws-credentials@v1
586
+ with:
587
+ aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
588
+ aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
589
+ aws-region: us-east-1
590
+
591
+ - name: Deploy Frigg App
592
+ run: |
593
+ frigg deploy
594
+ ```
595
+
596
+ This policy ensures your Frigg application can successfully discover AWS resources during build time and deploy all necessary infrastructure components during deployment.