@friggframework/devtools 2.0.0--canary.400.bed3308.0 → 2.0.0--canary.404.e9d4980.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.
Files changed (182) hide show
  1. package/frigg-cli/build-command/index.js +3 -18
  2. package/frigg-cli/deploy-command/index.js +3 -19
  3. package/frigg-cli/index.js +1 -73
  4. package/frigg-cli/install-command/index.js +2 -15
  5. package/frigg-cli/start-command/index.js +2 -17
  6. package/infrastructure/create-frigg-infrastructure.js +2 -2
  7. package/infrastructure/serverless-template.js +79 -529
  8. package/package.json +5 -9
  9. package/frigg-cli/.eslintrc.js +0 -141
  10. package/frigg-cli/__tests__/jest.config.js +0 -102
  11. package/frigg-cli/__tests__/unit/commands/build.test.js +0 -483
  12. package/frigg-cli/__tests__/unit/commands/install.test.js +0 -418
  13. package/frigg-cli/__tests__/unit/commands/ui.test.js +0 -592
  14. package/frigg-cli/__tests__/utils/command-tester.js +0 -170
  15. package/frigg-cli/__tests__/utils/mock-factory.js +0 -270
  16. package/frigg-cli/__tests__/utils/test-fixtures.js +0 -463
  17. package/frigg-cli/__tests__/utils/test-setup.js +0 -286
  18. package/frigg-cli/generate-command/__tests__/generate-command.test.js +0 -312
  19. package/frigg-cli/generate-command/azure-generator.js +0 -43
  20. package/frigg-cli/generate-command/gcp-generator.js +0 -47
  21. package/frigg-cli/generate-command/index.js +0 -350
  22. package/frigg-cli/generate-command/terraform-generator.js +0 -555
  23. package/frigg-cli/generate-iam-command.js +0 -115
  24. package/frigg-cli/package.json +0 -75
  25. package/frigg-cli/ui-command/index.js +0 -167
  26. package/frigg-cli/utils/app-resolver.js +0 -319
  27. package/frigg-cli/utils/backend-path.js +0 -38
  28. package/frigg-cli/utils/process-manager.js +0 -199
  29. package/frigg-cli/utils/repo-detection.js +0 -405
  30. package/infrastructure/AWS-DISCOVERY-TROUBLESHOOTING.md +0 -245
  31. package/infrastructure/AWS-IAM-CREDENTIAL-NEEDS.md +0 -620
  32. package/infrastructure/DEPLOYMENT-INSTRUCTIONS.md +0 -268
  33. package/infrastructure/GENERATE-IAM-DOCS.md +0 -253
  34. package/infrastructure/IAM-POLICY-TEMPLATES.md +0 -176
  35. package/infrastructure/README-TESTING.md +0 -332
  36. package/infrastructure/README.md +0 -421
  37. package/infrastructure/WEBSOCKET-CONFIGURATION.md +0 -105
  38. package/infrastructure/__tests__/fixtures/mock-aws-resources.js +0 -391
  39. package/infrastructure/__tests__/helpers/test-utils.js +0 -277
  40. package/infrastructure/aws-discovery.js +0 -568
  41. package/infrastructure/aws-discovery.test.js +0 -373
  42. package/infrastructure/build-time-discovery.js +0 -206
  43. package/infrastructure/build-time-discovery.test.js +0 -375
  44. package/infrastructure/frigg-deployment-iam-stack.yaml +0 -393
  45. package/infrastructure/iam-generator.js +0 -810
  46. package/infrastructure/iam-generator.test.js +0 -169
  47. package/infrastructure/iam-policy-basic.json +0 -236
  48. package/infrastructure/iam-policy-full.json +0 -305
  49. package/infrastructure/integration.test.js +0 -383
  50. package/infrastructure/run-discovery.js +0 -110
  51. package/infrastructure/serverless-template.test.js +0 -553
  52. package/management-ui/.eslintrc.js +0 -22
  53. package/management-ui/README.md +0 -203
  54. package/management-ui/components.json +0 -21
  55. package/management-ui/index.html +0 -13
  56. package/management-ui/merge-conflict-cleaner.py +0 -371
  57. package/management-ui/package-lock.json +0 -10997
  58. package/management-ui/package.json +0 -76
  59. package/management-ui/postcss.config.js +0 -6
  60. package/management-ui/server/api/backend.js +0 -256
  61. package/management-ui/server/api/cli.js +0 -315
  62. package/management-ui/server/api/codegen.js +0 -663
  63. package/management-ui/server/api/connections.js +0 -857
  64. package/management-ui/server/api/discovery.js +0 -185
  65. package/management-ui/server/api/environment/index.js +0 -1
  66. package/management-ui/server/api/environment/router.js +0 -378
  67. package/management-ui/server/api/environment.js +0 -328
  68. package/management-ui/server/api/integrations.js +0 -479
  69. package/management-ui/server/api/logs.js +0 -248
  70. package/management-ui/server/api/monitoring.js +0 -282
  71. package/management-ui/server/api/open-ide.js +0 -31
  72. package/management-ui/server/api/project.js +0 -553
  73. package/management-ui/server/api/users/sessions.js +0 -371
  74. package/management-ui/server/api/users/simulation.js +0 -254
  75. package/management-ui/server/api/users.js +0 -362
  76. package/management-ui/server/api-contract.md +0 -275
  77. package/management-ui/server/index.js +0 -428
  78. package/management-ui/server/middleware/errorHandler.js +0 -70
  79. package/management-ui/server/middleware/security.js +0 -32
  80. package/management-ui/server/processManager.js +0 -296
  81. package/management-ui/server/server.js +0 -188
  82. package/management-ui/server/services/aws-monitor.js +0 -413
  83. package/management-ui/server/services/npm-registry.js +0 -347
  84. package/management-ui/server/services/template-engine.js +0 -538
  85. package/management-ui/server/utils/cliIntegration.js +0 -220
  86. package/management-ui/server/utils/environment/auditLogger.js +0 -471
  87. package/management-ui/server/utils/environment/awsParameterStore.js +0 -264
  88. package/management-ui/server/utils/environment/encryption.js +0 -278
  89. package/management-ui/server/utils/environment/envFileManager.js +0 -286
  90. package/management-ui/server/utils/import-commonjs.js +0 -28
  91. package/management-ui/server/utils/response.js +0 -83
  92. package/management-ui/server/websocket/handler.js +0 -325
  93. package/management-ui/src/App.jsx +0 -51
  94. package/management-ui/src/assets/FriggLogo.svg +0 -1
  95. package/management-ui/src/components/AppRouter.jsx +0 -65
  96. package/management-ui/src/components/Button.jsx +0 -2
  97. package/management-ui/src/components/Card.jsx +0 -9
  98. package/management-ui/src/components/EnvironmentCompare.jsx +0 -400
  99. package/management-ui/src/components/EnvironmentEditor.jsx +0 -372
  100. package/management-ui/src/components/EnvironmentImportExport.jsx +0 -469
  101. package/management-ui/src/components/EnvironmentSchema.jsx +0 -491
  102. package/management-ui/src/components/EnvironmentSecurity.jsx +0 -463
  103. package/management-ui/src/components/ErrorBoundary.jsx +0 -73
  104. package/management-ui/src/components/IntegrationCard.jsx +0 -199
  105. package/management-ui/src/components/IntegrationCardEnhanced.jsx +0 -490
  106. package/management-ui/src/components/IntegrationExplorer.jsx +0 -379
  107. package/management-ui/src/components/IntegrationStatus.jsx +0 -235
  108. package/management-ui/src/components/Layout.jsx +0 -250
  109. package/management-ui/src/components/LoadingSpinner.jsx +0 -45
  110. package/management-ui/src/components/RepositoryPicker.jsx +0 -248
  111. package/management-ui/src/components/SessionMonitor.jsx +0 -255
  112. package/management-ui/src/components/StatusBadge.jsx +0 -70
  113. package/management-ui/src/components/UserContextSwitcher.jsx +0 -154
  114. package/management-ui/src/components/UserSimulation.jsx +0 -299
  115. package/management-ui/src/components/Welcome.jsx +0 -434
  116. package/management-ui/src/components/codegen/APIEndpointGenerator.jsx +0 -637
  117. package/management-ui/src/components/codegen/APIModuleSelector.jsx +0 -227
  118. package/management-ui/src/components/codegen/CodeGenerationWizard.jsx +0 -247
  119. package/management-ui/src/components/codegen/CodePreviewEditor.jsx +0 -316
  120. package/management-ui/src/components/codegen/DynamicModuleForm.jsx +0 -271
  121. package/management-ui/src/components/codegen/FormBuilder.jsx +0 -737
  122. package/management-ui/src/components/codegen/IntegrationGenerator.jsx +0 -855
  123. package/management-ui/src/components/codegen/ProjectScaffoldWizard.jsx +0 -797
  124. package/management-ui/src/components/codegen/SchemaBuilder.jsx +0 -303
  125. package/management-ui/src/components/codegen/TemplateSelector.jsx +0 -586
  126. package/management-ui/src/components/codegen/index.js +0 -10
  127. package/management-ui/src/components/connections/ConnectionConfigForm.jsx +0 -362
  128. package/management-ui/src/components/connections/ConnectionHealthMonitor.jsx +0 -182
  129. package/management-ui/src/components/connections/ConnectionTester.jsx +0 -200
  130. package/management-ui/src/components/connections/EntityRelationshipMapper.jsx +0 -292
  131. package/management-ui/src/components/connections/OAuthFlow.jsx +0 -204
  132. package/management-ui/src/components/connections/index.js +0 -5
  133. package/management-ui/src/components/index.js +0 -21
  134. package/management-ui/src/components/monitoring/APIGatewayMetrics.jsx +0 -222
  135. package/management-ui/src/components/monitoring/LambdaMetrics.jsx +0 -169
  136. package/management-ui/src/components/monitoring/MetricsChart.jsx +0 -197
  137. package/management-ui/src/components/monitoring/MonitoringDashboard.jsx +0 -393
  138. package/management-ui/src/components/monitoring/SQSMetrics.jsx +0 -246
  139. package/management-ui/src/components/monitoring/index.js +0 -6
  140. package/management-ui/src/components/monitoring/monitoring.css +0 -218
  141. package/management-ui/src/components/theme-provider.jsx +0 -52
  142. package/management-ui/src/components/theme-toggle.jsx +0 -39
  143. package/management-ui/src/components/ui/badge.tsx +0 -36
  144. package/management-ui/src/components/ui/button.test.jsx +0 -56
  145. package/management-ui/src/components/ui/button.tsx +0 -57
  146. package/management-ui/src/components/ui/card.tsx +0 -76
  147. package/management-ui/src/components/ui/dropdown-menu.tsx +0 -199
  148. package/management-ui/src/components/ui/select.tsx +0 -157
  149. package/management-ui/src/components/ui/skeleton.jsx +0 -15
  150. package/management-ui/src/hooks/useFrigg.jsx +0 -387
  151. package/management-ui/src/hooks/useSocket.jsx +0 -58
  152. package/management-ui/src/index.css +0 -194
  153. package/management-ui/src/lib/utils.ts +0 -6
  154. package/management-ui/src/main.jsx +0 -10
  155. package/management-ui/src/pages/CodeGeneration.jsx +0 -14
  156. package/management-ui/src/pages/Connections.jsx +0 -252
  157. package/management-ui/src/pages/ConnectionsEnhanced.jsx +0 -427
  158. package/management-ui/src/pages/Dashboard.jsx +0 -311
  159. package/management-ui/src/pages/Environment.jsx +0 -314
  160. package/management-ui/src/pages/IntegrationConfigure.jsx +0 -544
  161. package/management-ui/src/pages/IntegrationDiscovery.jsx +0 -479
  162. package/management-ui/src/pages/IntegrationTest.jsx +0 -494
  163. package/management-ui/src/pages/Integrations.jsx +0 -254
  164. package/management-ui/src/pages/Monitoring.jsx +0 -17
  165. package/management-ui/src/pages/Simulation.jsx +0 -155
  166. package/management-ui/src/pages/Users.jsx +0 -492
  167. package/management-ui/src/services/api.js +0 -41
  168. package/management-ui/src/services/apiModuleService.js +0 -193
  169. package/management-ui/src/services/websocket-handlers.js +0 -120
  170. package/management-ui/src/test/api/project.test.js +0 -273
  171. package/management-ui/src/test/components/Welcome.test.jsx +0 -378
  172. package/management-ui/src/test/mocks/server.js +0 -178
  173. package/management-ui/src/test/setup.js +0 -61
  174. package/management-ui/src/test/utils/test-utils.jsx +0 -134
  175. package/management-ui/src/utils/repository.js +0 -98
  176. package/management-ui/src/utils/repository.test.js +0 -118
  177. package/management-ui/src/workflows/phase2-integration-workflows.js +0 -884
  178. package/management-ui/tailwind.config.js +0 -63
  179. package/management-ui/tsconfig.json +0 -37
  180. package/management-ui/tsconfig.node.json +0 -10
  181. package/management-ui/vite.config.js +0 -26
  182. package/management-ui/vitest.config.js +0 -38
@@ -1,810 +0,0 @@
1
- const fs = require('fs-extra');
2
- const path = require('path');
3
-
4
- /**
5
- * Generate IAM CloudFormation template based on AppDefinition
6
- * @param {Object} appDefinition - Application definition object
7
- * @param {Object} options - Generation options
8
- * @param {string} [options.deploymentUserName='frigg-deployment-user'] - IAM user name
9
- * @param {string} [options.stackName='frigg-deployment-iam'] - CloudFormation stack name
10
- * @param {string} [options.mode='auto'] - Policy mode: 'basic', 'full', or 'auto' (auto-detect from appDefinition)
11
- * @returns {string} CloudFormation YAML template
12
- */
13
- function generateIAMCloudFormation(appDefinition, options = {}) {
14
- const {
15
- deploymentUserName = 'frigg-deployment-user',
16
- stackName = 'frigg-deployment-iam',
17
- mode = 'auto'
18
- } = options;
19
-
20
- // Determine which features are enabled based on mode
21
- let features;
22
- if (mode === 'basic') {
23
- features = {
24
- vpc: false,
25
- kms: false,
26
- ssm: false,
27
- websockets: appDefinition.websockets?.enable === true
28
- };
29
- } else if (mode === 'full') {
30
- features = {
31
- vpc: true,
32
- kms: true,
33
- ssm: true,
34
- websockets: appDefinition.websockets?.enable === true
35
- };
36
- } else { // mode === 'auto'
37
- features = {
38
- vpc: appDefinition.vpc?.enable === true,
39
- kms: appDefinition.encryption?.useDefaultKMSForFieldLevelEncryption === true,
40
- ssm: appDefinition.ssm?.enable === true,
41
- websockets: appDefinition.websockets?.enable === true
42
- };
43
- }
44
-
45
- // Build the CloudFormation template
46
- const template = {
47
- AWSTemplateFormatVersion: '2010-09-09',
48
- Description: `IAM roles and policies for ${appDefinition.name || 'Frigg'} application deployment pipeline`,
49
- <<<<<<< HEAD
50
- =======
51
-
52
- >>>>>>> 37c4892ee8a686eb7acfcd17c333b0ed73e1f120
53
- Parameters: {
54
- DeploymentUserName: {
55
- Type: 'String',
56
- Default: deploymentUserName,
57
- Description: 'Name for the IAM user that will deploy Frigg applications'
58
- },
59
- EnableVPCSupport: {
60
- Type: 'String',
61
- Default: features.vpc ? 'true' : 'false',
62
- AllowedValues: ['true', 'false'],
63
- Description: 'Enable VPC-related permissions for Frigg applications'
64
- },
65
- EnableKMSSupport: {
66
- Type: 'String',
67
- Default: features.kms ? 'true' : 'false',
68
- AllowedValues: ['true', 'false'],
69
- Description: 'Enable KMS encryption permissions for Frigg applications'
70
- },
71
- EnableSSMSupport: {
72
- Type: 'String',
73
- Default: features.ssm ? 'true' : 'false',
74
- AllowedValues: ['true', 'false'],
75
- Description: 'Enable SSM Parameter Store permissions for Frigg applications'
76
- }
77
- },
78
-
79
- Conditions: {
80
- CreateVPCPermissions: { 'Fn::Equals': [{ Ref: 'EnableVPCSupport' }, 'true'] },
81
- CreateKMSPermissions: { 'Fn::Equals': [{ Ref: 'EnableKMSSupport' }, 'true'] },
82
- CreateSSMPermissions: { 'Fn::Equals': [{ Ref: 'EnableSSMSupport' }, 'true'] }
83
- },
84
-
85
- Resources: {}
86
- };
87
-
88
- // Add IAM User
89
- template.Resources.FriggDeploymentUser = {
90
- Type: 'AWS::IAM::User',
91
- Properties: {
92
- UserName: { Ref: 'DeploymentUserName' },
93
- ManagedPolicyArns: [
94
- { Ref: 'FriggDiscoveryPolicy' },
95
- { Ref: 'FriggCoreDeploymentPolicy' }
96
- ]
97
- }
98
- };
99
-
100
- // Conditionally add feature-specific policies
101
- if (features.vpc) {
102
- template.Resources.FriggDeploymentUser.Properties.ManagedPolicyArns.push({
103
- 'Fn::If': ['CreateVPCPermissions', { Ref: 'FriggVPCPolicy' }, { Ref: 'AWS::NoValue' }]
104
- });
105
- }
106
- if (features.kms) {
107
- template.Resources.FriggDeploymentUser.Properties.ManagedPolicyArns.push({
108
- 'Fn::If': ['CreateKMSPermissions', { Ref: 'FriggKMSPolicy' }, { Ref: 'AWS::NoValue' }]
109
- });
110
- }
111
- if (features.ssm) {
112
- template.Resources.FriggDeploymentUser.Properties.ManagedPolicyArns.push({
113
- 'Fn::If': ['CreateSSMPermissions', { Ref: 'FriggSSMPolicy' }, { Ref: 'AWS::NoValue' }]
114
- });
115
- }
116
-
117
- // Add Access Key
118
- template.Resources.FriggDeploymentAccessKey = {
119
- Type: 'AWS::IAM::AccessKey',
120
- Properties: {
121
- UserName: { Ref: 'FriggDeploymentUser' }
122
- }
123
- };
124
-
125
- // Add Discovery Policy (always needed)
126
- template.Resources.FriggDiscoveryPolicy = {
127
- Type: 'AWS::IAM::ManagedPolicy',
128
- Properties: {
129
- ManagedPolicyName: 'FriggDiscoveryPolicy',
130
- Description: 'Permissions for AWS resource discovery during Frigg build process',
131
- PolicyDocument: {
132
- Version: '2012-10-17',
133
- Statement: [
134
- {
135
- Sid: 'AWSDiscoveryPermissions',
136
- Effect: 'Allow',
137
- Action: [
138
- 'sts:GetCallerIdentity',
139
- 'ec2:DescribeVpcs',
140
- 'ec2:DescribeSubnets',
141
- 'ec2:DescribeSecurityGroups',
142
- 'ec2:DescribeRouteTables',
143
- 'ec2:DescribeNatGateways',
144
- 'ec2:DescribeAddresses',
145
- 'kms:ListKeys',
146
- 'kms:DescribeKey'
147
- ],
148
- Resource: '*'
149
- }
150
- ]
151
- }
152
- }
153
- };
154
-
155
- // Add Core Deployment Policy (always needed)
156
- const coreActions = [
157
- // CloudFormation permissions
158
- 'cloudformation:CreateStack',
159
- 'cloudformation:UpdateStack',
160
- 'cloudformation:DeleteStack',
161
- 'cloudformation:DescribeStacks',
162
- 'cloudformation:DescribeStackEvents',
163
- 'cloudformation:DescribeStackResources',
164
- 'cloudformation:DescribeStackResource',
165
- 'cloudformation:ListStackResources',
166
- 'cloudformation:GetTemplate',
167
- 'cloudformation:DescribeChangeSet',
168
- 'cloudformation:CreateChangeSet',
169
- 'cloudformation:DeleteChangeSet',
170
- 'cloudformation:ExecuteChangeSet',
171
- 'cloudformation:ValidateTemplate',
172
- <<<<<<< HEAD
173
- =======
174
-
175
- >>>>>>> 37c4892ee8a686eb7acfcd17c333b0ed73e1f120
176
- // Lambda permissions
177
- 'lambda:CreateFunction',
178
- 'lambda:UpdateFunctionCode',
179
- 'lambda:UpdateFunctionConfiguration',
180
- 'lambda:DeleteFunction',
181
- 'lambda:GetFunction',
182
- 'lambda:ListFunctions',
183
- 'lambda:PublishVersion',
184
- 'lambda:CreateAlias',
185
- 'lambda:UpdateAlias',
186
- 'lambda:DeleteAlias',
187
- 'lambda:GetAlias',
188
- 'lambda:AddPermission',
189
- 'lambda:RemovePermission',
190
- 'lambda:GetPolicy',
191
- 'lambda:PutProvisionedConcurrencyConfig',
192
- 'lambda:DeleteProvisionedConcurrencyConfig',
193
- 'lambda:PutConcurrency',
194
- 'lambda:DeleteConcurrency',
195
- 'lambda:TagResource',
196
- 'lambda:UntagResource',
197
- 'lambda:ListVersionsByFunction',
198
- <<<<<<< HEAD
199
- =======
200
-
201
- >>>>>>> 37c4892ee8a686eb7acfcd17c333b0ed73e1f120
202
- // IAM permissions
203
- 'iam:CreateRole',
204
- 'iam:DeleteRole',
205
- 'iam:GetRole',
206
- 'iam:PassRole',
207
- 'iam:PutRolePolicy',
208
- 'iam:DeleteRolePolicy',
209
- 'iam:GetRolePolicy',
210
- 'iam:AttachRolePolicy',
211
- 'iam:DetachRolePolicy',
212
- 'iam:TagRole',
213
- 'iam:UntagRole',
214
- 'iam:ListPolicyVersions',
215
- <<<<<<< HEAD
216
-
217
- =======
218
-
219
- >>>>>>> 37c4892ee8a686eb7acfcd17c333b0ed73e1f120
220
- // S3 permissions
221
- 's3:CreateBucket',
222
- 's3:DeleteBucket',
223
- 's3:PutObject',
224
- 's3:GetObject',
225
- 's3:DeleteObject',
226
- 's3:PutBucketPolicy',
227
- 's3:GetBucketPolicy',
228
- 's3:DeleteBucketPolicy',
229
- 's3:PutBucketVersioning',
230
- 's3:GetBucketVersioning',
231
- 's3:PutBucketPublicAccessBlock',
232
- 's3:GetBucketPublicAccessBlock',
233
- 's3:PutBucketTagging',
234
- 's3:GetBucketTagging',
235
- 's3:DeleteBucketTagging',
236
- 's3:PutBucketEncryption',
237
- 's3:GetBucketEncryption',
238
- 's3:PutEncryptionConfiguration',
239
- 's3:PutBucketNotification',
240
- 's3:GetBucketNotification',
241
- 's3:GetBucketLocation',
242
- 's3:ListBucket',
243
- 's3:GetBucketAcl',
244
- 's3:PutBucketAcl',
245
- <<<<<<< HEAD
246
-
247
- =======
248
-
249
- >>>>>>> 37c4892ee8a686eb7acfcd17c333b0ed73e1f120
250
- // SQS permissions
251
- 'sqs:CreateQueue',
252
- 'sqs:DeleteQueue',
253
- 'sqs:GetQueueAttributes',
254
- 'sqs:SetQueueAttributes',
255
- 'sqs:GetQueueUrl',
256
- 'sqs:TagQueue',
257
- 'sqs:UntagQueue',
258
- <<<<<<< HEAD
259
- =======
260
-
261
- >>>>>>> 37c4892ee8a686eb7acfcd17c333b0ed73e1f120
262
- // SNS permissions
263
- 'sns:CreateTopic',
264
- 'sns:DeleteTopic',
265
- 'sns:GetTopicAttributes',
266
- 'sns:SetTopicAttributes',
267
- 'sns:Subscribe',
268
- 'sns:Unsubscribe',
269
- 'sns:ListSubscriptionsByTopic',
270
- 'sns:TagResource',
271
- 'sns:UntagResource',
272
- <<<<<<< HEAD
273
- =======
274
-
275
- >>>>>>> 37c4892ee8a686eb7acfcd17c333b0ed73e1f120
276
- // CloudWatch and Logs permissions
277
- 'cloudwatch:PutMetricAlarm',
278
- 'cloudwatch:DeleteAlarms',
279
- 'cloudwatch:DescribeAlarms',
280
- 'logs:CreateLogGroup',
281
- 'logs:CreateLogStream',
282
- 'logs:DeleteLogGroup',
283
- 'logs:DescribeLogGroups',
284
- 'logs:DescribeLogStreams',
285
- 'logs:FilterLogEvents',
286
- 'logs:PutLogEvents',
287
- 'logs:PutRetentionPolicy',
288
- <<<<<<< HEAD
289
- =======
290
-
291
- >>>>>>> 37c4892ee8a686eb7acfcd17c333b0ed73e1f120
292
- // API Gateway permissions
293
- 'apigateway:POST',
294
- 'apigateway:PUT',
295
- 'apigateway:DELETE',
296
- 'apigateway:GET',
297
- 'apigateway:PATCH'
298
- ];
299
-
300
- const coreStatements = [
301
- {
302
- Sid: 'CloudFormationFriggStacks',
303
- Effect: 'Allow',
304
- Action: [
305
- 'cloudformation:CreateStack',
306
- 'cloudformation:UpdateStack',
307
- 'cloudformation:DeleteStack',
308
- 'cloudformation:DescribeStacks',
309
- 'cloudformation:DescribeStackEvents',
310
- 'cloudformation:DescribeStackResources',
311
- 'cloudformation:DescribeStackResource',
312
- 'cloudformation:ListStackResources',
313
- 'cloudformation:GetTemplate',
314
- 'cloudformation:DescribeChangeSet',
315
- 'cloudformation:CreateChangeSet',
316
- 'cloudformation:DeleteChangeSet',
317
- 'cloudformation:ExecuteChangeSet',
318
- 'cloudformation:TagResource',
319
- 'cloudformation:UntagResource',
320
- 'cloudformation:ListStackResources'
321
- ],
322
- Resource: [
323
- { 'Fn::Sub': 'arn:aws:cloudformation:*:${AWS::AccountId}:stack/*frigg*/*' }
324
- ]
325
- },
326
- {
327
- Sid: 'CloudFormationValidateTemplate',
328
- Effect: 'Allow',
329
- Action: ['cloudformation:ValidateTemplate'],
330
- Resource: '*'
331
- },
332
- {
333
- Sid: 'S3DeploymentBucket',
334
- Effect: 'Allow',
335
- Action: [
336
- 's3:CreateBucket',
337
- 's3:DeleteBucket',
338
- 's3:PutObject',
339
- 's3:GetObject',
340
- 's3:DeleteObject',
341
- 's3:PutBucketPolicy',
342
- 's3:GetBucketPolicy',
343
- 's3:DeleteBucketPolicy',
344
- 's3:PutBucketVersioning',
345
- 's3:GetBucketVersioning',
346
- 's3:PutBucketPublicAccessBlock',
347
- 's3:GetBucketPublicAccessBlock',
348
- 's3:PutBucketTagging',
349
- 's3:GetBucketTagging',
350
- 's3:DeleteBucketTagging',
351
- 's3:PutBucketEncryption',
352
- 's3:GetBucketEncryption',
353
- 's3:PutEncryptionConfiguration',
354
- 's3:PutBucketNotification',
355
- 's3:GetBucketNotification',
356
- 's3:GetBucketLocation',
357
- 's3:ListBucket',
358
- 's3:GetBucketAcl',
359
- 's3:PutBucketAcl'
360
- ],
361
- Resource: [
362
- 'arn:aws:s3:::*serverless*',
363
- 'arn:aws:s3:::*serverless*/*'
364
- ]
365
- },
366
- {
367
- Sid: 'LambdaFriggFunctions',
368
- Effect: 'Allow',
369
- Action: [
370
- 'lambda:CreateFunction',
371
- 'lambda:UpdateFunctionCode',
372
- 'lambda:UpdateFunctionConfiguration',
373
- 'lambda:DeleteFunction',
374
- 'lambda:GetFunction',
375
- 'lambda:ListFunctions',
376
- 'lambda:PublishVersion',
377
- 'lambda:CreateAlias',
378
- 'lambda:UpdateAlias',
379
- 'lambda:DeleteAlias',
380
- 'lambda:GetAlias',
381
- 'lambda:AddPermission',
382
- 'lambda:RemovePermission',
383
- 'lambda:GetPolicy',
384
- 'lambda:PutProvisionedConcurrencyConfig',
385
- 'lambda:DeleteProvisionedConcurrencyConfig',
386
- 'lambda:PutConcurrency',
387
- 'lambda:PutFunctionConcurrency',
388
- 'lambda:DeleteConcurrency',
389
- 'lambda:TagResource',
390
- 'lambda:UntagResource',
391
- 'lambda:ListVersionsByFunction'
392
- ],
393
- Resource: [
394
- { 'Fn::Sub': 'arn:aws:lambda:*:${AWS::AccountId}:function:*frigg*' }
395
- ]
396
- },
397
- {
398
- Sid: 'FriggLambdaEventSourceMapping',
399
- Effect: 'Allow',
400
- Action: [
401
- 'lambda:CreateEventSourceMapping',
402
- 'lambda:DeleteEventSourceMapping',
403
- 'lambda:GetEventSourceMapping',
404
- 'lambda:UpdateEventSourceMapping',
405
- 'lambda:ListEventSourceMappings',
406
- 'lambda:TagResource',
407
- 'lambda:UntagResource',
408
- 'lambda:ListTags'
409
- ],
410
- Resource: [
411
- { 'Fn::Sub': 'arn:aws:lambda:*:${AWS::AccountId}:event-source-mapping:*' }
412
- ]
413
- },
414
- {
415
- Sid: 'IAMRolesForFriggLambda',
416
- Effect: 'Allow',
417
- Action: [
418
- 'iam:CreateRole',
419
- 'iam:DeleteRole',
420
- 'iam:GetRole',
421
- 'iam:PassRole',
422
- 'iam:PutRolePolicy',
423
- 'iam:DeleteRolePolicy',
424
- 'iam:GetRolePolicy',
425
- 'iam:AttachRolePolicy',
426
- 'iam:DetachRolePolicy',
427
- 'iam:TagRole',
428
- 'iam:UntagRole'
429
- ],
430
- Resource: [
431
- { 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:role/*frigg*' },
432
- { 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:role/*frigg*LambdaRole*' }
433
- ]
434
- },
435
- {
436
- Sid: 'IAMPolicyVersionPermissions',
437
- Effect: 'Allow',
438
- Action: ['iam:ListPolicyVersions'],
439
- Resource: [{ 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:policy/*' }]
440
- },
441
- {
442
- Sid: 'FriggMessagingServices',
443
- Effect: 'Allow',
444
- Action: [
445
- 'sqs:CreateQueue',
446
- 'sqs:DeleteQueue',
447
- 'sqs:GetQueueAttributes',
448
- 'sqs:SetQueueAttributes',
449
- 'sqs:GetQueueUrl',
450
- 'sqs:TagQueue',
451
- 'sqs:UntagQueue'
452
- ],
453
- Resource: [
454
- { 'Fn::Sub': 'arn:aws:sqs:*:${AWS::AccountId}:*frigg*' },
455
- { 'Fn::Sub': 'arn:aws:sqs:*:${AWS::AccountId}:internal-error-queue-*' }
456
- ]
457
- },
458
- {
459
- Sid: 'FriggSNSTopics',
460
- Effect: 'Allow',
461
- Action: [
462
- 'sns:CreateTopic',
463
- 'sns:DeleteTopic',
464
- 'sns:GetTopicAttributes',
465
- 'sns:SetTopicAttributes',
466
- 'sns:Subscribe',
467
- 'sns:Unsubscribe',
468
- 'sns:ListSubscriptionsByTopic',
469
- 'sns:TagResource',
470
- 'sns:UntagResource'
471
- ],
472
- Resource: [
473
- { 'Fn::Sub': 'arn:aws:sns:*:${AWS::AccountId}:*frigg*' }
474
- ]
475
- },
476
- {
477
- Sid: 'FriggMonitoringAndLogs',
478
- Effect: 'Allow',
479
- Action: [
480
- 'cloudwatch:PutMetricAlarm',
481
- 'cloudwatch:DeleteAlarms',
482
- 'cloudwatch:DescribeAlarms',
483
- 'logs:CreateLogGroup',
484
- 'logs:CreateLogStream',
485
- 'logs:DeleteLogGroup',
486
- 'logs:DescribeLogGroups',
487
- 'logs:DescribeLogStreams',
488
- 'logs:FilterLogEvents',
489
- 'logs:PutLogEvents',
490
- 'logs:PutRetentionPolicy',
491
- 'logs:TagResource',
492
- 'logs:UntagResource'
493
- ],
494
- Resource: [
495
- { 'Fn::Sub': 'arn:aws:logs:*:${AWS::AccountId}:log-group:/aws/lambda/*frigg*' },
496
- { 'Fn::Sub': 'arn:aws:logs:*:${AWS::AccountId}:log-group:/aws/lambda/*frigg*:*' },
497
- { 'Fn::Sub': 'arn:aws:cloudwatch:*:${AWS::AccountId}:alarm:*frigg*' }
498
- ]
499
- },
500
- {
501
- Sid: 'FriggAPIGateway',
502
- Effect: 'Allow',
503
- Action: [
504
- 'apigateway:POST',
505
- 'apigateway:PUT',
506
- 'apigateway:DELETE',
507
- 'apigateway:GET',
508
- 'apigateway:PATCH'
509
- ],
510
- Resource: [
511
- 'arn:aws:apigateway:*::/restapis',
512
- 'arn:aws:apigateway:*::/restapis/*',
513
- 'arn:aws:apigateway:*::/domainnames',
514
- 'arn:aws:apigateway:*::/domainnames/*',
515
- 'arn:aws:apigateway:*::/tags/*'
516
- ]
517
- }
518
- ];
519
-
520
- template.Resources.FriggCoreDeploymentPolicy = {
521
- Type: 'AWS::IAM::ManagedPolicy',
522
- Properties: {
523
- ManagedPolicyName: 'FriggCoreDeploymentPolicy',
524
- Description: 'Core permissions for deploying Frigg applications',
525
- PolicyDocument: {
526
- Version: '2012-10-17',
527
- Statement: coreStatements
528
- }
529
- }
530
- };
531
-
532
- // Add feature-specific policies only if needed
533
- if (features.vpc) {
534
- template.Resources.FriggVPCPolicy = {
535
- Type: 'AWS::IAM::ManagedPolicy',
536
- Condition: 'CreateVPCPermissions',
537
- Properties: {
538
- ManagedPolicyName: 'FriggVPCPolicy',
539
- Description: 'VPC-related permissions for Frigg applications',
540
- PolicyDocument: {
541
- Version: '2012-10-17',
542
- Statement: [
543
- {
544
- Sid: 'FriggVPCEndpointManagement',
545
- Effect: 'Allow',
546
- Action: [
547
- 'ec2:CreateVpcEndpoint',
548
- 'ec2:DeleteVpcEndpoint',
549
- 'ec2:DeleteVpcEndpoints',
550
- 'ec2:DescribeVpcEndpoints',
551
- 'ec2:ModifyVpcEndpoint',
552
- 'ec2:CreateNatGateway',
553
- 'ec2:DeleteNatGateway',
554
- 'ec2:DescribeNatGateways',
555
- 'ec2:AllocateAddress',
556
- 'ec2:ReleaseAddress',
557
- 'ec2:DescribeAddresses',
558
- 'ec2:AssociateAddress',
559
- 'ec2:DisassociateAddress',
560
- 'ec2:CreateRouteTable',
561
- 'ec2:DeleteRouteTable',
562
- 'ec2:DescribeRouteTables',
563
- 'ec2:CreateRoute',
564
- 'ec2:DeleteRoute',
565
- 'ec2:AssociateRouteTable',
566
- 'ec2:DisassociateRouteTable',
567
- 'ec2:CreateSecurityGroup',
568
- 'ec2:DeleteSecurityGroup',
569
- 'ec2:AuthorizeSecurityGroupEgress',
570
- 'ec2:AuthorizeSecurityGroupIngress',
571
- 'ec2:RevokeSecurityGroupEgress',
572
- 'ec2:RevokeSecurityGroupIngress',
573
- 'ec2:CreateTags',
574
- 'ec2:DeleteTags',
575
- 'ec2:DescribeTags'
576
- ],
577
- Resource: '*'
578
- }
579
- ]
580
- }
581
- }
582
- };
583
- }
584
-
585
- if (features.kms) {
586
- template.Resources.FriggKMSPolicy = {
587
- Type: 'AWS::IAM::ManagedPolicy',
588
- Condition: 'CreateKMSPermissions',
589
- Properties: {
590
- ManagedPolicyName: 'FriggKMSPolicy',
591
- Description: 'KMS encryption permissions for Frigg applications',
592
- PolicyDocument: {
593
- Version: '2012-10-17',
594
- Statement: [
595
- {
596
- Sid: 'FriggKMSEncryptionRuntime',
597
- Effect: 'Allow',
598
- Action: [
599
- 'kms:GenerateDataKey',
600
- 'kms:Decrypt'
601
- ],
602
- Resource: [
603
- { 'Fn::Sub': 'arn:aws:kms:*:${AWS::AccountId}:key/*' }
604
- ],
605
- Condition: {
606
- StringEquals: {
607
- 'kms:ViaService': [
608
- 'lambda.*.amazonaws.com',
609
- 's3.*.amazonaws.com'
610
- ]
611
- }
612
- }
613
- }
614
- ]
615
- }
616
- }
617
- };
618
- }
619
-
620
- if (features.ssm) {
621
- template.Resources.FriggSSMPolicy = {
622
- Type: 'AWS::IAM::ManagedPolicy',
623
- Condition: 'CreateSSMPermissions',
624
- Properties: {
625
- ManagedPolicyName: 'FriggSSMPolicy',
626
- Description: 'SSM Parameter Store permissions for Frigg applications',
627
- PolicyDocument: {
628
- Version: '2012-10-17',
629
- Statement: [
630
- {
631
- Sid: 'FriggSSMParameterAccess',
632
- Effect: 'Allow',
633
- Action: [
634
- 'ssm:GetParameter',
635
- 'ssm:GetParameters',
636
- 'ssm:GetParametersByPath'
637
- ],
638
- Resource: [
639
- { 'Fn::Sub': 'arn:aws:ssm:*:${AWS::AccountId}:parameter/*frigg*' },
640
- { 'Fn::Sub': 'arn:aws:ssm:*:${AWS::AccountId}:parameter/*frigg*/*' }
641
- ]
642
- }
643
- ]
644
- }
645
- }
646
- };
647
- }
648
-
649
- // Add Secrets Manager for credentials
650
- template.Resources.FriggDeploymentCredentials = {
651
- Type: 'AWS::SecretsManager::Secret',
652
- Properties: {
653
- Name: 'frigg-deployment-credentials',
654
- Description: 'Access credentials for Frigg deployment user',
655
- SecretString: {
656
- 'Fn::Sub': JSON.stringify({
657
- AccessKeyId: '${FriggDeploymentAccessKey}',
658
- SecretAccessKey: '${FriggDeploymentAccessKey.SecretAccessKey}'
659
- })
660
- }
661
- }
662
- };
663
-
664
- // Add Outputs
665
- template.Outputs = {
666
- DeploymentUserArn: {
667
- Description: 'ARN of the Frigg deployment user',
668
- Value: { 'Fn::GetAtt': ['FriggDeploymentUser', 'Arn'] },
669
- Export: {
670
- Name: { 'Fn::Sub': '${AWS::StackName}-UserArn' }
671
- }
672
- },
673
- AccessKeyId: {
674
- Description: 'Access Key ID for the deployment user',
675
- Value: { Ref: 'FriggDeploymentAccessKey' },
676
- Export: {
677
- Name: { 'Fn::Sub': '${AWS::StackName}-AccessKeyId' }
678
- }
679
- },
680
- SecretAccessKeyCommand: {
681
- Description: 'Command to retrieve the secret access key',
682
- Value: {
683
- 'Fn::Sub': 'aws secretsmanager get-secret-value --secret-id frigg-deployment-credentials --query SecretString --output text | jq -r .SecretAccessKey'
684
- }
685
- },
686
- CredentialsSecretArn: {
687
- Description: 'ARN of the secret containing deployment credentials',
688
- Value: { Ref: 'FriggDeploymentCredentials' },
689
- Export: {
690
- Name: { 'Fn::Sub': '${AWS::StackName}-CredentialsSecretArn' }
691
- }
692
- }
693
- };
694
-
695
- // Convert to YAML
696
- return convertToYAML(template);
697
- }
698
-
699
- /**
700
- * Convert JavaScript object to CloudFormation YAML
701
- * @param {Object} obj - JavaScript object
702
- * @returns {string} YAML string
703
- */
704
- function convertToYAML(obj) {
705
- const yaml = require('js-yaml');
706
- return yaml.dump(obj, {
707
- indent: 2,
708
- lineWidth: 120,
709
- noRefs: true,
710
- sortKeys: false
711
- });
712
- }
713
-
714
- /**
715
- * Generate summary of what features will be included in the IAM policy
716
- * @param {Object} appDefinition - Application definition
717
- * @returns {Object} Feature summary
718
- */
719
- function getFeatureSummary(appDefinition) {
720
- const features = {
721
- core: true, // Always enabled
722
- vpc: appDefinition.vpc?.enable === true,
723
- kms: appDefinition.encryption?.useDefaultKMSForFieldLevelEncryption === true,
724
- ssm: appDefinition.ssm?.enable === true,
725
- websockets: appDefinition.websockets?.enable === true
726
- };
727
-
728
- const integrationCount = appDefinition.integrations?.length || 0;
729
-
730
- return {
731
- features,
732
- integrationCount,
733
- appName: appDefinition.name || 'Unnamed Frigg App'
734
- };
735
- }
736
-
737
- /**
738
- * Generate basic IAM policy (JSON format) - Core Frigg permissions only
739
- * @returns {Object} Basic IAM policy document
740
- */
741
- function generateBasicIAMPolicy() {
742
- const basicPolicyPath = path.join(__dirname, 'iam-policy-basic.json');
743
- return require(basicPolicyPath);
744
- }
745
-
746
- /**
747
- * Generate full IAM policy (JSON format) - All features enabled
748
- * @returns {Object} Full IAM policy document
749
- */
750
- function generateFullIAMPolicy() {
751
- const fullPolicyPath = path.join(__dirname, 'iam-policy-full.json');
752
- return require(fullPolicyPath);
753
- }
754
-
755
- /**
756
- * Generate IAM policy based on mode
757
- * @param {string} mode - 'basic' or 'full'
758
- * @returns {Object} IAM policy document
759
- */
760
- function generateIAMPolicy(mode = 'basic') {
761
- if (mode === 'full') {
762
- return generateFullIAMPolicy();
763
- }
764
- return generateBasicIAMPolicy();
765
- }
766
-
767
- /**
768
- * Wrapper function for generate command compatibility
769
- * @param {Object} options - Generation options
770
- * @param {string} options.appName - Application name
771
- * @param {Object} options.features - Feature flags
772
- * @param {string} options.userPrefix - IAM user name prefix
773
- * @param {string} options.stackName - CloudFormation stack name
774
- * @returns {Promise<string>} CloudFormation YAML template
775
- */
776
- async function generateCloudFormationTemplate(options) {
777
- const { appName, features, userPrefix, stackName } = options;
778
- <<<<<<< HEAD
779
-
780
- =======
781
-
782
- >>>>>>> 37c4892ee8a686eb7acfcd17c333b0ed73e1f120
783
- // Create appDefinition from features
784
- const appDefinition = {
785
- name: appName,
786
- vpc: { enable: features.vpc },
787
- encryption: { useDefaultKMSForFieldLevelEncryption: features.kms },
788
- ssm: { enable: features.ssm },
789
- websockets: { enable: features.websockets }
790
- };
791
- <<<<<<< HEAD
792
-
793
- =======
794
-
795
- >>>>>>> 37c4892ee8a686eb7acfcd17c333b0ed73e1f120
796
- return generateIAMCloudFormation(appDefinition, {
797
- deploymentUserName: userPrefix,
798
- stackName: stackName,
799
- mode: 'auto'
800
- });
801
- }
802
-
803
- module.exports = {
804
- generateIAMCloudFormation,
805
- getFeatureSummary,
806
- generateBasicIAMPolicy,
807
- generateFullIAMPolicy,
808
- generateIAMPolicy,
809
- generateCloudFormationTemplate
810
- };