@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.
- package/frigg-cli/.eslintrc.js +141 -0
- package/frigg-cli/__tests__/jest.config.js +102 -0
- package/frigg-cli/__tests__/unit/commands/build.test.js +483 -0
- package/frigg-cli/__tests__/unit/commands/install.test.js +418 -0
- package/frigg-cli/__tests__/unit/commands/ui.test.js +592 -0
- package/frigg-cli/__tests__/utils/command-tester.js +170 -0
- package/frigg-cli/__tests__/utils/mock-factory.js +270 -0
- package/frigg-cli/__tests__/utils/test-fixtures.js +463 -0
- package/frigg-cli/__tests__/utils/test-setup.js +286 -0
- package/frigg-cli/build-command/index.js +54 -0
- package/frigg-cli/deploy-command/index.js +36 -0
- package/frigg-cli/generate-command/__tests__/generate-command.test.js +312 -0
- package/frigg-cli/generate-command/azure-generator.js +43 -0
- package/frigg-cli/generate-command/gcp-generator.js +47 -0
- package/frigg-cli/generate-command/index.js +332 -0
- package/frigg-cli/generate-command/terraform-generator.js +555 -0
- package/frigg-cli/generate-iam-command.js +115 -0
- package/frigg-cli/index.js +47 -1
- package/frigg-cli/index.test.js +1 -4
- package/frigg-cli/init-command/backend-first-handler.js +756 -0
- package/frigg-cli/init-command/index.js +93 -0
- package/frigg-cli/init-command/template-handler.js +143 -0
- package/frigg-cli/install-command/index.js +1 -4
- package/frigg-cli/package.json +51 -0
- package/frigg-cli/start-command/index.js +24 -4
- package/frigg-cli/test/init-command.test.js +180 -0
- package/frigg-cli/test/npm-registry.test.js +319 -0
- package/frigg-cli/ui-command/index.js +154 -0
- package/frigg-cli/utils/app-resolver.js +319 -0
- package/frigg-cli/utils/backend-path.js +16 -17
- package/frigg-cli/utils/npm-registry.js +167 -0
- package/frigg-cli/utils/process-manager.js +199 -0
- package/frigg-cli/utils/repo-detection.js +405 -0
- package/infrastructure/AWS-DISCOVERY-TROUBLESHOOTING.md +245 -0
- package/infrastructure/AWS-IAM-CREDENTIAL-NEEDS.md +596 -0
- package/infrastructure/DEPLOYMENT-INSTRUCTIONS.md +268 -0
- package/infrastructure/GENERATE-IAM-DOCS.md +253 -0
- package/infrastructure/IAM-POLICY-TEMPLATES.md +176 -0
- package/infrastructure/README-TESTING.md +332 -0
- package/infrastructure/README.md +421 -0
- package/infrastructure/WEBSOCKET-CONFIGURATION.md +105 -0
- package/infrastructure/__tests__/fixtures/mock-aws-resources.js +391 -0
- package/infrastructure/__tests__/helpers/test-utils.js +277 -0
- package/infrastructure/aws-discovery.js +568 -0
- package/infrastructure/aws-discovery.test.js +373 -0
- package/infrastructure/build-time-discovery.js +206 -0
- package/infrastructure/build-time-discovery.test.js +375 -0
- package/infrastructure/create-frigg-infrastructure.js +3 -5
- package/infrastructure/frigg-deployment-iam-stack.yaml +379 -0
- package/infrastructure/iam-generator.js +687 -0
- package/infrastructure/iam-generator.test.js +169 -0
- package/infrastructure/iam-policy-basic.json +212 -0
- package/infrastructure/iam-policy-full.json +282 -0
- package/infrastructure/integration.test.js +383 -0
- package/infrastructure/run-discovery.js +110 -0
- package/infrastructure/serverless-template.js +923 -113
- package/infrastructure/serverless-template.test.js +541 -0
- package/management-ui/.eslintrc.js +22 -0
- package/management-ui/README.md +203 -0
- package/management-ui/components.json +21 -0
- package/management-ui/docs/phase2-integration-guide.md +320 -0
- package/management-ui/index.html +13 -0
- package/management-ui/package-lock.json +16517 -0
- package/management-ui/package.json +76 -0
- package/management-ui/packages/devtools/frigg-cli/ui-command/index.js +302 -0
- package/management-ui/postcss.config.js +6 -0
- package/management-ui/server/api/backend.js +256 -0
- package/management-ui/server/api/cli.js +315 -0
- package/management-ui/server/api/codegen.js +663 -0
- package/management-ui/server/api/connections.js +857 -0
- package/management-ui/server/api/discovery.js +185 -0
- package/management-ui/server/api/environment/index.js +1 -0
- package/management-ui/server/api/environment/router.js +378 -0
- package/management-ui/server/api/environment.js +328 -0
- package/management-ui/server/api/integrations.js +876 -0
- package/management-ui/server/api/logs.js +248 -0
- package/management-ui/server/api/monitoring.js +282 -0
- package/management-ui/server/api/open-ide.js +31 -0
- package/management-ui/server/api/project.js +1029 -0
- package/management-ui/server/api/users/sessions.js +371 -0
- package/management-ui/server/api/users/simulation.js +254 -0
- package/management-ui/server/api/users.js +362 -0
- package/management-ui/server/api-contract.md +275 -0
- package/management-ui/server/index.js +873 -0
- package/management-ui/server/middleware/errorHandler.js +93 -0
- package/management-ui/server/middleware/security.js +32 -0
- package/management-ui/server/processManager.js +296 -0
- package/management-ui/server/server.js +346 -0
- package/management-ui/server/services/aws-monitor.js +413 -0
- package/management-ui/server/services/npm-registry.js +347 -0
- package/management-ui/server/services/template-engine.js +538 -0
- package/management-ui/server/utils/cliIntegration.js +220 -0
- package/management-ui/server/utils/environment/auditLogger.js +471 -0
- package/management-ui/server/utils/environment/awsParameterStore.js +264 -0
- package/management-ui/server/utils/environment/encryption.js +278 -0
- package/management-ui/server/utils/environment/envFileManager.js +286 -0
- package/management-ui/server/utils/import-commonjs.js +28 -0
- package/management-ui/server/utils/response.js +83 -0
- package/management-ui/server/websocket/handler.js +325 -0
- package/management-ui/src/App.jsx +109 -0
- package/management-ui/src/assets/FriggLogo.svg +1 -0
- package/management-ui/src/components/AppRouter.jsx +65 -0
- package/management-ui/src/components/Button.jsx +70 -0
- package/management-ui/src/components/Card.jsx +97 -0
- package/management-ui/src/components/EnvironmentCompare.jsx +400 -0
- package/management-ui/src/components/EnvironmentEditor.jsx +372 -0
- package/management-ui/src/components/EnvironmentImportExport.jsx +469 -0
- package/management-ui/src/components/EnvironmentSchema.jsx +491 -0
- package/management-ui/src/components/EnvironmentSecurity.jsx +463 -0
- package/management-ui/src/components/ErrorBoundary.jsx +73 -0
- package/management-ui/src/components/IntegrationCard.jsx +481 -0
- package/management-ui/src/components/IntegrationCardEnhanced.jsx +770 -0
- package/management-ui/src/components/IntegrationExplorer.jsx +379 -0
- package/management-ui/src/components/IntegrationStatus.jsx +336 -0
- package/management-ui/src/components/Layout.jsx +716 -0
- package/management-ui/src/components/LoadingSpinner.jsx +113 -0
- package/management-ui/src/components/RepositoryPicker.jsx +248 -0
- package/management-ui/src/components/SessionMonitor.jsx +350 -0
- package/management-ui/src/components/StatusBadge.jsx +208 -0
- package/management-ui/src/components/UserContextSwitcher.jsx +212 -0
- package/management-ui/src/components/UserSimulation.jsx +327 -0
- package/management-ui/src/components/Welcome.jsx +434 -0
- package/management-ui/src/components/codegen/APIEndpointGenerator.jsx +637 -0
- package/management-ui/src/components/codegen/APIModuleSelector.jsx +227 -0
- package/management-ui/src/components/codegen/CodeGenerationWizard.jsx +247 -0
- package/management-ui/src/components/codegen/CodePreviewEditor.jsx +316 -0
- package/management-ui/src/components/codegen/DynamicModuleForm.jsx +271 -0
- package/management-ui/src/components/codegen/FormBuilder.jsx +737 -0
- package/management-ui/src/components/codegen/IntegrationGenerator.jsx +855 -0
- package/management-ui/src/components/codegen/ProjectScaffoldWizard.jsx +797 -0
- package/management-ui/src/components/codegen/SchemaBuilder.jsx +303 -0
- package/management-ui/src/components/codegen/TemplateSelector.jsx +586 -0
- package/management-ui/src/components/codegen/index.js +10 -0
- package/management-ui/src/components/connections/ConnectionConfigForm.jsx +362 -0
- package/management-ui/src/components/connections/ConnectionHealthMonitor.jsx +182 -0
- package/management-ui/src/components/connections/ConnectionTester.jsx +200 -0
- package/management-ui/src/components/connections/EntityRelationshipMapper.jsx +292 -0
- package/management-ui/src/components/connections/OAuthFlow.jsx +204 -0
- package/management-ui/src/components/connections/index.js +5 -0
- package/management-ui/src/components/index.js +21 -0
- package/management-ui/src/components/monitoring/APIGatewayMetrics.jsx +222 -0
- package/management-ui/src/components/monitoring/LambdaMetrics.jsx +169 -0
- package/management-ui/src/components/monitoring/MetricsChart.jsx +197 -0
- package/management-ui/src/components/monitoring/MonitoringDashboard.jsx +393 -0
- package/management-ui/src/components/monitoring/SQSMetrics.jsx +246 -0
- package/management-ui/src/components/monitoring/index.js +6 -0
- package/management-ui/src/components/monitoring/monitoring.css +218 -0
- package/management-ui/src/components/theme-provider.jsx +52 -0
- package/management-ui/src/components/theme-toggle.jsx +39 -0
- package/management-ui/src/components/ui/badge.tsx +36 -0
- package/management-ui/src/components/ui/button.test.jsx +56 -0
- package/management-ui/src/components/ui/button.tsx +57 -0
- package/management-ui/src/components/ui/card.tsx +76 -0
- package/management-ui/src/components/ui/dropdown-menu.tsx +199 -0
- package/management-ui/src/components/ui/select.tsx +157 -0
- package/management-ui/src/components/ui/skeleton.jsx +15 -0
- package/management-ui/src/hooks/useFrigg.jsx +601 -0
- package/management-ui/src/hooks/useSocket.jsx +58 -0
- package/management-ui/src/index.css +193 -0
- package/management-ui/src/lib/utils.ts +6 -0
- package/management-ui/src/main.jsx +10 -0
- package/management-ui/src/pages/CodeGeneration.jsx +14 -0
- package/management-ui/src/pages/Connections.jsx +252 -0
- package/management-ui/src/pages/ConnectionsEnhanced.jsx +633 -0
- package/management-ui/src/pages/Dashboard.jsx +311 -0
- package/management-ui/src/pages/Environment.jsx +314 -0
- package/management-ui/src/pages/IntegrationConfigure.jsx +669 -0
- package/management-ui/src/pages/IntegrationDiscovery.jsx +567 -0
- package/management-ui/src/pages/IntegrationTest.jsx +742 -0
- package/management-ui/src/pages/Integrations.jsx +253 -0
- package/management-ui/src/pages/Monitoring.jsx +17 -0
- package/management-ui/src/pages/Simulation.jsx +155 -0
- package/management-ui/src/pages/Users.jsx +492 -0
- package/management-ui/src/services/api.js +41 -0
- package/management-ui/src/services/apiModuleService.js +193 -0
- package/management-ui/src/services/websocket-handlers.js +120 -0
- package/management-ui/src/test/api/project.test.js +273 -0
- package/management-ui/src/test/components/Welcome.test.jsx +378 -0
- package/management-ui/src/test/mocks/server.js +178 -0
- package/management-ui/src/test/setup.js +61 -0
- package/management-ui/src/test/utils/test-utils.jsx +134 -0
- package/management-ui/src/utils/repository.js +98 -0
- package/management-ui/src/utils/repository.test.js +118 -0
- package/management-ui/src/workflows/phase2-integration-workflows.js +884 -0
- package/management-ui/tailwind.config.js +63 -0
- package/management-ui/tsconfig.json +37 -0
- package/management-ui/tsconfig.node.json +10 -0
- package/management-ui/vite.config.js +26 -0
- package/management-ui/vitest.config.js +38 -0
- package/package.json +16 -9
- package/infrastructure/app-handler-helpers.js +0 -57
- package/infrastructure/backend-utils.js +0 -90
- package/infrastructure/routers/auth.js +0 -26
- package/infrastructure/routers/integration-defined-routers.js +0 -37
- package/infrastructure/routers/middleware/loadUser.js +0 -15
- package/infrastructure/routers/middleware/requireLoggedInUser.js +0 -12
- package/infrastructure/routers/user.js +0 -41
- package/infrastructure/routers/websocket.js +0 -55
- package/infrastructure/workers/integration-defined-workers.js +0 -24
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
async function generateTerraformTemplate(options) {
|
|
2
|
+
const { appName, features, userPrefix } = options;
|
|
3
|
+
const userName = `${userPrefix}-${appName}`.replace(/[^a-zA-Z0-9-]/g, '-');
|
|
4
|
+
|
|
5
|
+
let template = `# Frigg Deployment IAM Configuration for ${appName}
|
|
6
|
+
# Generated by Frigg CLI
|
|
7
|
+
|
|
8
|
+
terraform {
|
|
9
|
+
required_providers {
|
|
10
|
+
aws = {
|
|
11
|
+
source = "hashicorp/aws"
|
|
12
|
+
version = "~> 5.0"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# Variables
|
|
18
|
+
variable "enable_vpc" {
|
|
19
|
+
description = "Enable VPC permissions"
|
|
20
|
+
type = bool
|
|
21
|
+
default = ${features.vpc}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
variable "enable_kms" {
|
|
25
|
+
description = "Enable KMS permissions"
|
|
26
|
+
type = bool
|
|
27
|
+
default = ${features.kms}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
variable "enable_ssm" {
|
|
31
|
+
description = "Enable SSM Parameter Store permissions"
|
|
32
|
+
type = bool
|
|
33
|
+
default = ${features.ssm}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
variable "enable_websockets" {
|
|
37
|
+
description = "Enable WebSocket permissions"
|
|
38
|
+
type = bool
|
|
39
|
+
default = ${features.websockets}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# IAM User
|
|
43
|
+
resource "aws_iam_user" "frigg_deployment" {
|
|
44
|
+
name = "${userName}"
|
|
45
|
+
path = "/deployment/"
|
|
46
|
+
|
|
47
|
+
tags = {
|
|
48
|
+
Application = "${appName}"
|
|
49
|
+
ManagedBy = "Frigg"
|
|
50
|
+
Purpose = "Deployment"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# Access Key
|
|
55
|
+
resource "aws_iam_access_key" "frigg_deployment" {
|
|
56
|
+
user = aws_iam_user.frigg_deployment.name
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Core Discovery Policy
|
|
60
|
+
resource "aws_iam_policy" "frigg_discovery" {
|
|
61
|
+
name = "${userName}-discovery-policy"
|
|
62
|
+
description = "Allows discovery of AWS resources for Frigg deployment"
|
|
63
|
+
|
|
64
|
+
policy = jsonencode({
|
|
65
|
+
Version = "2012-10-17"
|
|
66
|
+
Statement = [
|
|
67
|
+
{
|
|
68
|
+
Effect = "Allow"
|
|
69
|
+
Action = [
|
|
70
|
+
"cloudformation:ListStacks",
|
|
71
|
+
"cloudformation:DescribeStacks",
|
|
72
|
+
"lambda:ListFunctions",
|
|
73
|
+
"lambda:GetFunction",
|
|
74
|
+
"apigateway:GET",
|
|
75
|
+
"s3:ListAllMyBuckets",
|
|
76
|
+
"s3:GetBucketLocation",
|
|
77
|
+
"s3:GetBucketVersioning",
|
|
78
|
+
"dynamodb:ListTables",
|
|
79
|
+
"dynamodb:DescribeTable",
|
|
80
|
+
"sqs:ListQueues",
|
|
81
|
+
"sqs:GetQueueAttributes",
|
|
82
|
+
"events:ListRules",
|
|
83
|
+
"events:DescribeRule",
|
|
84
|
+
"iam:GetRole",
|
|
85
|
+
"iam:GetPolicy",
|
|
86
|
+
"iam:GetPolicyVersion",
|
|
87
|
+
"iam:ListAttachedRolePolicies",
|
|
88
|
+
"tag:GetResources"
|
|
89
|
+
]
|
|
90
|
+
Resource = "*"
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
# Core Deployment Policy
|
|
97
|
+
resource "aws_iam_policy" "frigg_core_deployment" {
|
|
98
|
+
name = "${userName}-core-deployment-policy"
|
|
99
|
+
description = "Core permissions for Frigg deployment"
|
|
100
|
+
|
|
101
|
+
policy = jsonencode({
|
|
102
|
+
Version = "2012-10-17"
|
|
103
|
+
Statement = [
|
|
104
|
+
{
|
|
105
|
+
Sid = "CloudFormationManagement"
|
|
106
|
+
Effect = "Allow"
|
|
107
|
+
Action = [
|
|
108
|
+
"cloudformation:CreateStack",
|
|
109
|
+
"cloudformation:UpdateStack",
|
|
110
|
+
"cloudformation:DeleteStack",
|
|
111
|
+
"cloudformation:DescribeStacks",
|
|
112
|
+
"cloudformation:DescribeStackEvents",
|
|
113
|
+
"cloudformation:DescribeStackResources",
|
|
114
|
+
"cloudformation:DescribeStackResource",
|
|
115
|
+
"cloudformation:ListStackResources",
|
|
116
|
+
"cloudformation:GetTemplate",
|
|
117
|
+
"cloudformation:ValidateTemplate",
|
|
118
|
+
"cloudformation:CreateChangeSet",
|
|
119
|
+
"cloudformation:DeleteChangeSet",
|
|
120
|
+
"cloudformation:DescribeChangeSet",
|
|
121
|
+
"cloudformation:ExecuteChangeSet",
|
|
122
|
+
"cloudformation:TagResource",
|
|
123
|
+
"cloudformation:UntagResource"
|
|
124
|
+
]
|
|
125
|
+
Resource = [
|
|
126
|
+
"arn:aws:cloudformation:*:*:stack/*frigg*/*",
|
|
127
|
+
"arn:aws:cloudformation:*:*:stack/${appName}*/*"
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
Sid = "S3Management"
|
|
132
|
+
Effect = "Allow"
|
|
133
|
+
Action = [
|
|
134
|
+
"s3:CreateBucket",
|
|
135
|
+
"s3:DeleteBucket",
|
|
136
|
+
"s3:PutObject",
|
|
137
|
+
"s3:GetObject",
|
|
138
|
+
"s3:DeleteObject",
|
|
139
|
+
"s3:PutBucketPolicy",
|
|
140
|
+
"s3:GetBucketPolicy",
|
|
141
|
+
"s3:DeleteBucketPolicy",
|
|
142
|
+
"s3:PutBucketVersioning",
|
|
143
|
+
"s3:GetBucketVersioning",
|
|
144
|
+
"s3:PutBucketPublicAccessBlock",
|
|
145
|
+
"s3:GetBucketPublicAccessBlock",
|
|
146
|
+
"s3:PutBucketTagging",
|
|
147
|
+
"s3:GetBucketTagging",
|
|
148
|
+
"s3:DeleteBucketTagging",
|
|
149
|
+
"s3:PutBucketEncryption",
|
|
150
|
+
"s3:GetBucketEncryption",
|
|
151
|
+
"s3:PutEncryptionConfiguration",
|
|
152
|
+
"s3:PutBucketNotification",
|
|
153
|
+
"s3:GetBucketNotification",
|
|
154
|
+
"s3:GetBucketLocation",
|
|
155
|
+
"s3:ListBucket",
|
|
156
|
+
"s3:GetBucketAcl",
|
|
157
|
+
"s3:PutBucketAcl"
|
|
158
|
+
]
|
|
159
|
+
Resource = [
|
|
160
|
+
"arn:aws:s3:::*frigg*",
|
|
161
|
+
"arn:aws:s3:::*frigg*/*",
|
|
162
|
+
"arn:aws:s3:::${appName}*",
|
|
163
|
+
"arn:aws:s3:::${appName}*/*"
|
|
164
|
+
]
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
Sid = "LambdaManagement"
|
|
168
|
+
Effect = "Allow"
|
|
169
|
+
Action = [
|
|
170
|
+
"lambda:CreateFunction",
|
|
171
|
+
"lambda:UpdateFunctionCode",
|
|
172
|
+
"lambda:UpdateFunctionConfiguration",
|
|
173
|
+
"lambda:DeleteFunction",
|
|
174
|
+
"lambda:GetFunction",
|
|
175
|
+
"lambda:GetFunctionConfiguration",
|
|
176
|
+
"lambda:AddPermission",
|
|
177
|
+
"lambda:RemovePermission",
|
|
178
|
+
"lambda:InvokeFunction",
|
|
179
|
+
"lambda:TagResource",
|
|
180
|
+
"lambda:UntagResource",
|
|
181
|
+
"lambda:ListTags",
|
|
182
|
+
"lambda:PutFunctionConcurrency",
|
|
183
|
+
"lambda:DeleteFunctionConcurrency"
|
|
184
|
+
]
|
|
185
|
+
Resource = [
|
|
186
|
+
"arn:aws:lambda:*:*:function:*frigg*",
|
|
187
|
+
"arn:aws:lambda:*:*:function:${appName}*"
|
|
188
|
+
]
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
Sid = "IAMRoleManagement"
|
|
192
|
+
Effect = "Allow"
|
|
193
|
+
Action = [
|
|
194
|
+
"iam:CreateRole",
|
|
195
|
+
"iam:DeleteRole",
|
|
196
|
+
"iam:AttachRolePolicy",
|
|
197
|
+
"iam:DetachRolePolicy",
|
|
198
|
+
"iam:PutRolePolicy",
|
|
199
|
+
"iam:DeleteRolePolicy",
|
|
200
|
+
"iam:GetRole",
|
|
201
|
+
"iam:GetRolePolicy",
|
|
202
|
+
"iam:UpdateRole",
|
|
203
|
+
"iam:PassRole",
|
|
204
|
+
"iam:TagRole",
|
|
205
|
+
"iam:UntagRole"
|
|
206
|
+
]
|
|
207
|
+
Resource = [
|
|
208
|
+
"arn:aws:iam::*:role/*frigg*",
|
|
209
|
+
"arn:aws:iam::*:role/${appName}*"
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
Sid = "APIGatewayManagement"
|
|
214
|
+
Effect = "Allow"
|
|
215
|
+
Action = [
|
|
216
|
+
"apigateway:*"
|
|
217
|
+
]
|
|
218
|
+
Resource = [
|
|
219
|
+
"arn:aws:apigateway:*::/restapis",
|
|
220
|
+
"arn:aws:apigateway:*::/restapis/*",
|
|
221
|
+
"arn:aws:apigateway:*::/apis",
|
|
222
|
+
"arn:aws:apigateway:*::/apis/*",
|
|
223
|
+
"arn:aws:apigateway:*::/tags/*"
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
Sid = "DynamoDBManagement"
|
|
228
|
+
Effect = "Allow"
|
|
229
|
+
Action = [
|
|
230
|
+
"dynamodb:CreateTable",
|
|
231
|
+
"dynamodb:UpdateTable",
|
|
232
|
+
"dynamodb:DeleteTable",
|
|
233
|
+
"dynamodb:DescribeTable",
|
|
234
|
+
"dynamodb:TagResource",
|
|
235
|
+
"dynamodb:UntagResource",
|
|
236
|
+
"dynamodb:ListTagsOfResource",
|
|
237
|
+
"dynamodb:UpdateTimeToLive",
|
|
238
|
+
"dynamodb:DescribeTimeToLive",
|
|
239
|
+
"dynamodb:CreateBackup",
|
|
240
|
+
"dynamodb:DeleteBackup",
|
|
241
|
+
"dynamodb:DescribeBackup",
|
|
242
|
+
"dynamodb:ListBackups"
|
|
243
|
+
]
|
|
244
|
+
Resource = [
|
|
245
|
+
"arn:aws:dynamodb:*:*:table/*frigg*",
|
|
246
|
+
"arn:aws:dynamodb:*:*:table/${appName}*"
|
|
247
|
+
]
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
Sid = "EventBridgeManagement"
|
|
251
|
+
Effect = "Allow"
|
|
252
|
+
Action = [
|
|
253
|
+
"events:PutRule",
|
|
254
|
+
"events:DeleteRule",
|
|
255
|
+
"events:DescribeRule",
|
|
256
|
+
"events:EnableRule",
|
|
257
|
+
"events:DisableRule",
|
|
258
|
+
"events:PutTargets",
|
|
259
|
+
"events:RemoveTargets",
|
|
260
|
+
"events:ListTargetsByRule",
|
|
261
|
+
"events:TagResource",
|
|
262
|
+
"events:UntagResource"
|
|
263
|
+
]
|
|
264
|
+
Resource = [
|
|
265
|
+
"arn:aws:events:*:*:rule/*frigg*",
|
|
266
|
+
"arn:aws:events:*:*:rule/${appName}*"
|
|
267
|
+
]
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
Sid = "SQSManagement"
|
|
271
|
+
Effect = "Allow"
|
|
272
|
+
Action = [
|
|
273
|
+
"sqs:CreateQueue",
|
|
274
|
+
"sqs:DeleteQueue",
|
|
275
|
+
"sqs:SetQueueAttributes",
|
|
276
|
+
"sqs:GetQueueAttributes",
|
|
277
|
+
"sqs:TagQueue",
|
|
278
|
+
"sqs:UntagQueue",
|
|
279
|
+
"sqs:ListQueueTags",
|
|
280
|
+
"sqs:AddPermission",
|
|
281
|
+
"sqs:RemovePermission"
|
|
282
|
+
]
|
|
283
|
+
Resource = [
|
|
284
|
+
"arn:aws:sqs:*:*:*frigg*",
|
|
285
|
+
"arn:aws:sqs:*:*:${appName}*"
|
|
286
|
+
]
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
Sid = "LogsManagement"
|
|
290
|
+
Effect = "Allow"
|
|
291
|
+
Action = [
|
|
292
|
+
"logs:CreateLogGroup",
|
|
293
|
+
"logs:DeleteLogGroup",
|
|
294
|
+
"logs:PutRetentionPolicy",
|
|
295
|
+
"logs:DeleteRetentionPolicy",
|
|
296
|
+
"logs:TagLogGroup",
|
|
297
|
+
"logs:UntagLogGroup"
|
|
298
|
+
]
|
|
299
|
+
Resource = [
|
|
300
|
+
"arn:aws:logs:*:*:log-group:/aws/lambda/*frigg*",
|
|
301
|
+
"arn:aws:logs:*:*:log-group:/aws/lambda/${appName}*",
|
|
302
|
+
"arn:aws:logs:*:*:log-group:/aws/apigateway/*frigg*",
|
|
303
|
+
"arn:aws:logs:*:*:log-group:/aws/apigateway/${appName}*"
|
|
304
|
+
]
|
|
305
|
+
}
|
|
306
|
+
]
|
|
307
|
+
})
|
|
308
|
+
}
|
|
309
|
+
`;
|
|
310
|
+
|
|
311
|
+
// Add VPC policy if enabled
|
|
312
|
+
if (features.vpc) {
|
|
313
|
+
template += `
|
|
314
|
+
# VPC Management Policy
|
|
315
|
+
resource "aws_iam_policy" "frigg_vpc" {
|
|
316
|
+
name = "${userName}-vpc-policy"
|
|
317
|
+
description = "VPC management permissions for Frigg"
|
|
318
|
+
|
|
319
|
+
policy = jsonencode({
|
|
320
|
+
Version = "2012-10-17"
|
|
321
|
+
Statement = [
|
|
322
|
+
{
|
|
323
|
+
Sid = "VPCDiscovery"
|
|
324
|
+
Effect = "Allow"
|
|
325
|
+
Action = [
|
|
326
|
+
"ec2:DescribeVpcs",
|
|
327
|
+
"ec2:DescribeSubnets",
|
|
328
|
+
"ec2:DescribeSecurityGroups",
|
|
329
|
+
"ec2:DescribeRouteTables",
|
|
330
|
+
"ec2:DescribeNatGateways",
|
|
331
|
+
"ec2:DescribeInternetGateways",
|
|
332
|
+
"ec2:DescribeVpcEndpoints",
|
|
333
|
+
"ec2:DescribeNetworkInterfaces",
|
|
334
|
+
"ec2:DescribeAddresses"
|
|
335
|
+
]
|
|
336
|
+
Resource = "*"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
Sid = "VPCManagement"
|
|
340
|
+
Effect = "Allow"
|
|
341
|
+
Action = [
|
|
342
|
+
"ec2:CreateVpc",
|
|
343
|
+
"ec2:DeleteVpc",
|
|
344
|
+
"ec2:ModifyVpcAttribute",
|
|
345
|
+
"ec2:CreateSubnet",
|
|
346
|
+
"ec2:DeleteSubnet",
|
|
347
|
+
"ec2:CreateSecurityGroup",
|
|
348
|
+
"ec2:DeleteSecurityGroup",
|
|
349
|
+
"ec2:AuthorizeSecurityGroupIngress",
|
|
350
|
+
"ec2:AuthorizeSecurityGroupEgress",
|
|
351
|
+
"ec2:RevokeSecurityGroupIngress",
|
|
352
|
+
"ec2:RevokeSecurityGroupEgress",
|
|
353
|
+
"ec2:CreateRouteTable",
|
|
354
|
+
"ec2:DeleteRouteTable",
|
|
355
|
+
"ec2:CreateRoute",
|
|
356
|
+
"ec2:DeleteRoute",
|
|
357
|
+
"ec2:AssociateRouteTable",
|
|
358
|
+
"ec2:DisassociateRouteTable",
|
|
359
|
+
"ec2:CreateInternetGateway",
|
|
360
|
+
"ec2:DeleteInternetGateway",
|
|
361
|
+
"ec2:AttachInternetGateway",
|
|
362
|
+
"ec2:DetachInternetGateway",
|
|
363
|
+
"ec2:CreateNatGateway",
|
|
364
|
+
"ec2:DeleteNatGateway",
|
|
365
|
+
"ec2:AllocateAddress",
|
|
366
|
+
"ec2:ReleaseAddress",
|
|
367
|
+
"ec2:CreateVpcEndpoint",
|
|
368
|
+
"ec2:DeleteVpcEndpoints",
|
|
369
|
+
"ec2:CreateTags",
|
|
370
|
+
"ec2:DeleteTags"
|
|
371
|
+
]
|
|
372
|
+
Resource = "*"
|
|
373
|
+
Condition = {
|
|
374
|
+
StringLike = {
|
|
375
|
+
"aws:RequestTag/Name" = ["*frigg*", "*${appName}*"]
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
]
|
|
380
|
+
})
|
|
381
|
+
}
|
|
382
|
+
`;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// Add KMS policy if enabled
|
|
386
|
+
if (features.kms) {
|
|
387
|
+
template += `
|
|
388
|
+
# KMS Management Policy
|
|
389
|
+
resource "aws_iam_policy" "frigg_kms" {
|
|
390
|
+
name = "${userName}-kms-policy"
|
|
391
|
+
description = "KMS management permissions for Frigg"
|
|
392
|
+
|
|
393
|
+
policy = jsonencode({
|
|
394
|
+
Version = "2012-10-17"
|
|
395
|
+
Statement = [
|
|
396
|
+
{
|
|
397
|
+
Sid = "KMSKeyManagement"
|
|
398
|
+
Effect = "Allow"
|
|
399
|
+
Action = [
|
|
400
|
+
"kms:CreateKey",
|
|
401
|
+
"kms:DescribeKey",
|
|
402
|
+
"kms:ListKeys",
|
|
403
|
+
"kms:ListAliases",
|
|
404
|
+
"kms:CreateAlias",
|
|
405
|
+
"kms:UpdateAlias",
|
|
406
|
+
"kms:DeleteAlias",
|
|
407
|
+
"kms:EnableKey",
|
|
408
|
+
"kms:DisableKey",
|
|
409
|
+
"kms:ScheduleKeyDeletion",
|
|
410
|
+
"kms:CancelKeyDeletion",
|
|
411
|
+
"kms:GetKeyPolicy",
|
|
412
|
+
"kms:PutKeyPolicy",
|
|
413
|
+
"kms:TagResource",
|
|
414
|
+
"kms:UntagResource",
|
|
415
|
+
"kms:ListResourceTags",
|
|
416
|
+
"kms:Encrypt",
|
|
417
|
+
"kms:Decrypt",
|
|
418
|
+
"kms:GenerateDataKey"
|
|
419
|
+
]
|
|
420
|
+
Resource = "*"
|
|
421
|
+
}
|
|
422
|
+
]
|
|
423
|
+
})
|
|
424
|
+
}
|
|
425
|
+
`;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
// Add SSM policy if enabled
|
|
429
|
+
if (features.ssm) {
|
|
430
|
+
template += `
|
|
431
|
+
# SSM Parameter Store Policy
|
|
432
|
+
resource "aws_iam_policy" "frigg_ssm" {
|
|
433
|
+
name = "${userName}-ssm-policy"
|
|
434
|
+
description = "SSM Parameter Store permissions for Frigg"
|
|
435
|
+
|
|
436
|
+
policy = jsonencode({
|
|
437
|
+
Version = "2012-10-17"
|
|
438
|
+
Statement = [
|
|
439
|
+
{
|
|
440
|
+
Sid = "SSMParameterManagement"
|
|
441
|
+
Effect = "Allow"
|
|
442
|
+
Action = [
|
|
443
|
+
"ssm:PutParameter",
|
|
444
|
+
"ssm:GetParameter",
|
|
445
|
+
"ssm:GetParameters",
|
|
446
|
+
"ssm:GetParametersByPath",
|
|
447
|
+
"ssm:DeleteParameter",
|
|
448
|
+
"ssm:DeleteParameters",
|
|
449
|
+
"ssm:DescribeParameters",
|
|
450
|
+
"ssm:AddTagsToResource",
|
|
451
|
+
"ssm:RemoveTagsFromResource",
|
|
452
|
+
"ssm:ListTagsForResource"
|
|
453
|
+
]
|
|
454
|
+
Resource = [
|
|
455
|
+
"arn:aws:ssm:*:*:parameter/*frigg*",
|
|
456
|
+
"arn:aws:ssm:*:*:parameter/${appName}*"
|
|
457
|
+
]
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
Sid = "SSMParameterDiscovery"
|
|
461
|
+
Effect = "Allow"
|
|
462
|
+
Action = [
|
|
463
|
+
"ssm:DescribeParameters"
|
|
464
|
+
]
|
|
465
|
+
Resource = "*"
|
|
466
|
+
}
|
|
467
|
+
]
|
|
468
|
+
})
|
|
469
|
+
}
|
|
470
|
+
`;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// Attach policies to user
|
|
474
|
+
template += `
|
|
475
|
+
# Attach policies to user
|
|
476
|
+
resource "aws_iam_user_policy_attachment" "frigg_discovery" {
|
|
477
|
+
user = aws_iam_user.frigg_deployment.name
|
|
478
|
+
policy_arn = aws_iam_policy.frigg_discovery.arn
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
resource "aws_iam_user_policy_attachment" "frigg_core_deployment" {
|
|
482
|
+
user = aws_iam_user.frigg_deployment.name
|
|
483
|
+
policy_arn = aws_iam_policy.frigg_core_deployment.arn
|
|
484
|
+
}
|
|
485
|
+
`;
|
|
486
|
+
|
|
487
|
+
if (features.vpc) {
|
|
488
|
+
template += `
|
|
489
|
+
resource "aws_iam_user_policy_attachment" "frigg_vpc" {
|
|
490
|
+
count = var.enable_vpc ? 1 : 0
|
|
491
|
+
user = aws_iam_user.frigg_deployment.name
|
|
492
|
+
policy_arn = aws_iam_policy.frigg_vpc.arn
|
|
493
|
+
}
|
|
494
|
+
`;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
if (features.kms) {
|
|
498
|
+
template += `
|
|
499
|
+
resource "aws_iam_user_policy_attachment" "frigg_kms" {
|
|
500
|
+
count = var.enable_kms ? 1 : 0
|
|
501
|
+
user = aws_iam_user.frigg_deployment.name
|
|
502
|
+
policy_arn = aws_iam_policy.frigg_kms.arn
|
|
503
|
+
}
|
|
504
|
+
`;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (features.ssm) {
|
|
508
|
+
template += `
|
|
509
|
+
resource "aws_iam_user_policy_attachment" "frigg_ssm" {
|
|
510
|
+
count = var.enable_ssm ? 1 : 0
|
|
511
|
+
user = aws_iam_user.frigg_deployment.name
|
|
512
|
+
policy_arn = aws_iam_policy.frigg_ssm.arn
|
|
513
|
+
}
|
|
514
|
+
`;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// Add outputs
|
|
518
|
+
template += `
|
|
519
|
+
# Outputs
|
|
520
|
+
output "user_arn" {
|
|
521
|
+
description = "ARN of the created IAM user"
|
|
522
|
+
value = aws_iam_user.frigg_deployment.arn
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
output "user_name" {
|
|
526
|
+
description = "Name of the created IAM user"
|
|
527
|
+
value = aws_iam_user.frigg_deployment.name
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
output "access_key_id" {
|
|
531
|
+
description = "Access key ID for the IAM user"
|
|
532
|
+
value = aws_iam_access_key.frigg_deployment.id
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
output "secret_access_key" {
|
|
536
|
+
description = "Secret access key for the IAM user"
|
|
537
|
+
value = aws_iam_access_key.frigg_deployment.secret
|
|
538
|
+
sensitive = true
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
output "enabled_features" {
|
|
542
|
+
description = "Features enabled for this deployment user"
|
|
543
|
+
value = {
|
|
544
|
+
vpc = var.enable_vpc
|
|
545
|
+
kms = var.enable_kms
|
|
546
|
+
ssm = var.enable_ssm
|
|
547
|
+
websockets = var.enable_websockets
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
`;
|
|
551
|
+
|
|
552
|
+
return template;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
module.exports = { generateTerraformTemplate };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const fs = require('fs-extra');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { findNearestBackendPackageJson } = require('@friggframework/core');
|
|
4
|
+
const { generateIAMCloudFormation, getFeatureSummary } = require('../infrastructure/iam-generator');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generate IAM CloudFormation stack based on current app definition
|
|
8
|
+
* @param {Object} options - Command options
|
|
9
|
+
*/
|
|
10
|
+
async function generateIamCommand(options = {}) {
|
|
11
|
+
try {
|
|
12
|
+
console.log('š Finding Frigg application...');
|
|
13
|
+
|
|
14
|
+
// Find the backend package.json
|
|
15
|
+
const backendPath = findNearestBackendPackageJson();
|
|
16
|
+
if (!backendPath) {
|
|
17
|
+
console.error('ā Could not find backend package.json');
|
|
18
|
+
console.error(' Make sure you are in a Frigg application directory');
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const backendDir = path.dirname(backendPath);
|
|
23
|
+
const backendFilePath = path.join(backendDir, 'index.js');
|
|
24
|
+
|
|
25
|
+
if (!fs.existsSync(backendFilePath)) {
|
|
26
|
+
console.error('ā Could not find backend/index.js');
|
|
27
|
+
console.error(' Make sure your Frigg application has a backend/index.js file');
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
console.log(`š± Found Frigg application at: ${backendDir}`);
|
|
32
|
+
|
|
33
|
+
// Load the app definition
|
|
34
|
+
const backend = require(backendFilePath);
|
|
35
|
+
const appDefinition = backend.Definition;
|
|
36
|
+
|
|
37
|
+
if (!appDefinition) {
|
|
38
|
+
console.error('ā No Definition found in backend/index.js');
|
|
39
|
+
console.error(' Make sure your backend exports a Definition object');
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Get feature summary
|
|
44
|
+
const summary = getFeatureSummary(appDefinition);
|
|
45
|
+
|
|
46
|
+
console.log('\\nš Application Analysis:');
|
|
47
|
+
console.log(` App Name: ${summary.appName}`);
|
|
48
|
+
console.log(` Integrations: ${summary.integrationCount}`);
|
|
49
|
+
console.log('\\nš§ Features Detected:');
|
|
50
|
+
console.log(` ā
Core deployment (always included)`);
|
|
51
|
+
console.log(` ${summary.features.vpc ? 'ā
' : 'ā'} VPC support`);
|
|
52
|
+
console.log(` ${summary.features.kms ? 'ā
' : 'ā'} KMS encryption`);
|
|
53
|
+
console.log(` ${summary.features.ssm ? 'ā
' : 'ā'} SSM Parameter Store`);
|
|
54
|
+
console.log(` ${summary.features.websockets ? 'ā
' : 'ā'} WebSocket support`);
|
|
55
|
+
|
|
56
|
+
// Generate the CloudFormation template
|
|
57
|
+
console.log('\\nšļø Generating IAM CloudFormation template...');
|
|
58
|
+
|
|
59
|
+
const deploymentUserName = options.user || 'frigg-deployment-user';
|
|
60
|
+
const stackName = options.stackName || 'frigg-deployment-iam';
|
|
61
|
+
|
|
62
|
+
const cloudFormationYaml = generateIAMCloudFormation(appDefinition, {
|
|
63
|
+
deploymentUserName,
|
|
64
|
+
stackName
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Determine output file path
|
|
68
|
+
const outputDir = options.output || path.join(backendDir, 'infrastructure');
|
|
69
|
+
await fs.ensureDir(outputDir);
|
|
70
|
+
|
|
71
|
+
const outputFile = path.join(outputDir, `${stackName}.yaml`);
|
|
72
|
+
|
|
73
|
+
// Write the file
|
|
74
|
+
await fs.writeFile(outputFile, cloudFormationYaml);
|
|
75
|
+
|
|
76
|
+
console.log(`\\nā
IAM CloudFormation template generated successfully!`);
|
|
77
|
+
console.log(`š File: ${outputFile}`);
|
|
78
|
+
|
|
79
|
+
// Show deployment instructions
|
|
80
|
+
console.log('\\nš Next Steps:');
|
|
81
|
+
console.log('\\n1. Deploy the CloudFormation stack:');
|
|
82
|
+
console.log(` aws cloudformation deploy \\\\`);
|
|
83
|
+
console.log(` --template-file ${path.relative(process.cwd(), outputFile)} \\\\`);
|
|
84
|
+
console.log(` --stack-name ${stackName} \\\\`);
|
|
85
|
+
console.log(` --capabilities CAPABILITY_NAMED_IAM \\\\`);
|
|
86
|
+
console.log(` --parameter-overrides DeploymentUserName=${deploymentUserName}`);
|
|
87
|
+
|
|
88
|
+
console.log('\\n2. Retrieve credentials:');
|
|
89
|
+
console.log(` aws cloudformation describe-stacks \\\\`);
|
|
90
|
+
console.log(` --stack-name ${stackName} \\\\`);
|
|
91
|
+
console.log(` --query 'Stacks[0].Outputs[?OutputKey==\`AccessKeyId\`].OutputValue' \\\\`);
|
|
92
|
+
console.log(` --output text`);
|
|
93
|
+
|
|
94
|
+
console.log('\\n3. Get secret access key:');
|
|
95
|
+
console.log(` aws secretsmanager get-secret-value \\\\`);
|
|
96
|
+
console.log(` --secret-id frigg-deployment-credentials \\\\`);
|
|
97
|
+
console.log(` --query SecretString \\\\`);
|
|
98
|
+
console.log(` --output text | jq -r .SecretAccessKey`);
|
|
99
|
+
|
|
100
|
+
if (options.verbose) {
|
|
101
|
+
console.log('\\nš Generated Template Summary:');
|
|
102
|
+
console.log(` File size: ${Math.round(cloudFormationYaml.length / 1024)}KB`);
|
|
103
|
+
console.log(` Features enabled: ${Object.values(summary.features).filter(Boolean).length}`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.error('ā Error generating IAM template:', error.message);
|
|
108
|
+
if (options.verbose) {
|
|
109
|
+
console.error('Stack trace:', error.stack);
|
|
110
|
+
}
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports = { generateIamCommand };
|