@friggframework/devtools 2.0.0-next.4 → 2.0.0-next.41
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 +175 -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 +30 -4
- package/frigg-cli/start-command/start-command.test.js +155 -0
- 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/DEPLOYMENT-INSTRUCTIONS.md +268 -0
- package/infrastructure/GENERATE-IAM-DOCS.md +278 -0
- package/infrastructure/IAM-POLICY-TEMPLATES.md +176 -0
- package/infrastructure/README.md +443 -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 +1176 -0
- package/infrastructure/aws-discovery.test.js +1220 -0
- package/infrastructure/build-time-discovery.js +206 -0
- package/infrastructure/build-time-discovery.test.js +378 -0
- package/infrastructure/create-frigg-infrastructure.js +3 -5
- package/infrastructure/env-validator.js +77 -0
- package/infrastructure/frigg-deployment-iam-stack.yaml +401 -0
- package/infrastructure/iam-generator.js +836 -0
- package/infrastructure/iam-generator.test.js +172 -0
- package/infrastructure/iam-policy-basic.json +218 -0
- package/infrastructure/iam-policy-full.json +288 -0
- package/infrastructure/integration.test.js +383 -0
- package/infrastructure/run-discovery.js +110 -0
- package/infrastructure/serverless-template.js +1493 -138
- package/infrastructure/serverless-template.test.js +1804 -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 +20 -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,268 @@
|
|
|
1
|
+
# Frigg IAM Deployment Instructions
|
|
2
|
+
|
|
3
|
+
This guide explains how to deploy the IAM CloudFormation stack to create the necessary AWS credentials for your Frigg deployment pipeline.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- AWS CLI installed and configured with administrator privileges
|
|
8
|
+
- AWS account ID
|
|
9
|
+
- Appropriate permissions to create IAM resources
|
|
10
|
+
|
|
11
|
+
## Deployment Steps
|
|
12
|
+
|
|
13
|
+
You can deploy the stack using either the AWS Management Console (UI) or AWS CLI.
|
|
14
|
+
|
|
15
|
+
### Option A: Deploy via AWS Management Console (UI)
|
|
16
|
+
|
|
17
|
+
#### 1. Upload and Create Stack
|
|
18
|
+
|
|
19
|
+
1. Log in to the [AWS Management Console](https://console.aws.amazon.com/)
|
|
20
|
+
2. Navigate to **CloudFormation** service
|
|
21
|
+
3. Click **Create stack** → **With new resources (standard)**
|
|
22
|
+
4. In the **Specify template** section:
|
|
23
|
+
- Select **Upload a template file**
|
|
24
|
+
- Click **Choose file** and select `frigg-deployment-iam-stack.yaml`
|
|
25
|
+
- Click **Next**
|
|
26
|
+
|
|
27
|
+
#### 2. Configure Stack Details
|
|
28
|
+
|
|
29
|
+
1. **Stack name**: Enter `frigg-deployment-iam`
|
|
30
|
+
2. **Parameters**:
|
|
31
|
+
- **DeploymentUserName**: `frigg-deployment-user` (or customize)
|
|
32
|
+
- **EnableVPCSupport**: `true`
|
|
33
|
+
- **EnableKMSSupport**: `true`
|
|
34
|
+
- **EnableSSMSupport**: `true`
|
|
35
|
+
3. Click **Next**
|
|
36
|
+
|
|
37
|
+
#### 3. Configure Stack Options
|
|
38
|
+
|
|
39
|
+
1. Leave all options as default (or configure tags if needed)
|
|
40
|
+
2. Click **Next**
|
|
41
|
+
|
|
42
|
+
#### 4. Review and Create
|
|
43
|
+
|
|
44
|
+
1. Review all settings
|
|
45
|
+
2. **Important**: Check the box that says **"I acknowledge that AWS CloudFormation might create IAM resources with custom names"**
|
|
46
|
+
3. Click **Submit**
|
|
47
|
+
4. Wait for the stack to reach **CREATE_COMPLETE** status (usually 2-3 minutes)
|
|
48
|
+
|
|
49
|
+
#### 5. Retrieve Credentials from Console
|
|
50
|
+
|
|
51
|
+
1. Once the stack is created, click on the stack name
|
|
52
|
+
2. Go to the **Outputs** tab
|
|
53
|
+
3. Note the **AccessKeyId** value
|
|
54
|
+
4. To get the Secret Access Key:
|
|
55
|
+
- Click on the **Resources** tab
|
|
56
|
+
- Find **FriggDeploymentCredentials** and click on its Physical ID link
|
|
57
|
+
- This will take you to AWS Secrets Manager
|
|
58
|
+
- Click **Retrieve secret value**
|
|
59
|
+
- Copy the **SecretAccessKey** value
|
|
60
|
+
|
|
61
|
+
### Option B: Deploy via AWS CLI
|
|
62
|
+
|
|
63
|
+
#### 1. Deploy the CloudFormation Stack
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
aws cloudformation deploy \
|
|
67
|
+
--template-file frigg-deployment-iam-stack.yaml \
|
|
68
|
+
--stack-name frigg-deployment-iam \
|
|
69
|
+
--capabilities CAPABILITY_NAMED_IAM \
|
|
70
|
+
--parameter-overrides \
|
|
71
|
+
DeploymentUserName=frigg-deployment-user \
|
|
72
|
+
EnableVPCSupport=true \
|
|
73
|
+
EnableKMSSupport=true \
|
|
74
|
+
EnableSSMSupport=true
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### 2. Retrieve Deployment Credentials
|
|
78
|
+
|
|
79
|
+
After successful deployment, retrieve the credentials:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Get the Access Key ID
|
|
83
|
+
aws cloudformation describe-stacks \
|
|
84
|
+
--stack-name frigg-deployment-iam \
|
|
85
|
+
--query 'Stacks[0].Outputs[?OutputKey==`AccessKeyId`].OutputValue' \
|
|
86
|
+
--output text
|
|
87
|
+
|
|
88
|
+
# Get the Secret Access Key from Secrets Manager
|
|
89
|
+
aws secretsmanager get-secret-value \
|
|
90
|
+
--secret-id frigg-deployment-credentials \
|
|
91
|
+
--query SecretString \
|
|
92
|
+
--output text | jq -r .SecretAccessKey
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 3. Configure CI/CD Environment
|
|
96
|
+
|
|
97
|
+
#### GitHub Actions
|
|
98
|
+
|
|
99
|
+
Add these secrets to your GitHub repository:
|
|
100
|
+
|
|
101
|
+
1. Go to Settings → Secrets and variables → Actions
|
|
102
|
+
2. Add new repository secrets:
|
|
103
|
+
- `AWS_ACCESS_KEY_ID`: The Access Key ID from step 2
|
|
104
|
+
- `AWS_SECRET_ACCESS_KEY`: The Secret Access Key from step 2
|
|
105
|
+
|
|
106
|
+
Example GitHub Actions workflow:
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
name: Deploy Frigg Application
|
|
110
|
+
on:
|
|
111
|
+
push:
|
|
112
|
+
branches: [main]
|
|
113
|
+
|
|
114
|
+
jobs:
|
|
115
|
+
deploy:
|
|
116
|
+
runs-on: ubuntu-latest
|
|
117
|
+
steps:
|
|
118
|
+
- uses: actions/checkout@v3
|
|
119
|
+
|
|
120
|
+
- name: Configure AWS credentials
|
|
121
|
+
uses: aws-actions/configure-aws-credentials@v2
|
|
122
|
+
with:
|
|
123
|
+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
124
|
+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
125
|
+
aws-region: us-east-1
|
|
126
|
+
|
|
127
|
+
- name: Install dependencies
|
|
128
|
+
run: npm install
|
|
129
|
+
|
|
130
|
+
- name: Deploy Frigg application
|
|
131
|
+
run: npx frigg deploy
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### GitLab CI/CD
|
|
135
|
+
|
|
136
|
+
Add variables in Settings → CI/CD → Variables:
|
|
137
|
+
|
|
138
|
+
```yaml
|
|
139
|
+
deploy:
|
|
140
|
+
image: node:18
|
|
141
|
+
before_script:
|
|
142
|
+
- npm install
|
|
143
|
+
script:
|
|
144
|
+
- export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
|
|
145
|
+
- export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
|
|
146
|
+
- export AWS_REGION=us-east-1
|
|
147
|
+
- npx frigg deploy
|
|
148
|
+
only:
|
|
149
|
+
- main
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### Jenkins
|
|
153
|
+
|
|
154
|
+
Store credentials in Jenkins Credentials Manager and use in pipeline:
|
|
155
|
+
|
|
156
|
+
```groovy
|
|
157
|
+
pipeline {
|
|
158
|
+
agent any
|
|
159
|
+
environment {
|
|
160
|
+
AWS_ACCESS_KEY_ID = credentials('frigg-aws-access-key-id')
|
|
161
|
+
AWS_SECRET_ACCESS_KEY = credentials('frigg-aws-secret-access-key')
|
|
162
|
+
AWS_REGION = 'us-east-1'
|
|
163
|
+
}
|
|
164
|
+
stages {
|
|
165
|
+
stage('Deploy') {
|
|
166
|
+
steps {
|
|
167
|
+
sh 'npm install'
|
|
168
|
+
sh 'npx frigg deploy'
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 4. Local Development Setup
|
|
176
|
+
|
|
177
|
+
For local development, configure AWS CLI profile:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Option 1: Use AWS CLI configure
|
|
181
|
+
aws configure --profile frigg-deployment
|
|
182
|
+
# Enter the Access Key ID and Secret Access Key when prompted
|
|
183
|
+
|
|
184
|
+
# Option 2: Add to ~/.aws/credentials manually
|
|
185
|
+
[frigg-deployment]
|
|
186
|
+
aws_access_key_id = YOUR_ACCESS_KEY_ID
|
|
187
|
+
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Use the profile in your deployment:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
export AWS_PROFILE=frigg-deployment
|
|
194
|
+
npx frigg deploy
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Stack Parameters
|
|
198
|
+
|
|
199
|
+
- **DeploymentUserName**: Name of the IAM user (default: `frigg-deployment-user`)
|
|
200
|
+
- **EnableVPCSupport**: Enable VPC-related permissions (default: `true`)
|
|
201
|
+
- **EnableKMSSupport**: Enable KMS encryption permissions (default: `true`)
|
|
202
|
+
- **EnableSSMSupport**: Enable SSM Parameter Store permissions (default: `true`)
|
|
203
|
+
|
|
204
|
+
## Security Best Practices
|
|
205
|
+
|
|
206
|
+
1. **Rotate Credentials Regularly**: Create a new access key periodically and update your CI/CD systems
|
|
207
|
+
2. **Use Separate Stacks**: Deploy separate stacks for dev, staging, and production environments
|
|
208
|
+
3. **Enable MFA**: For production deployments, consider using IAM roles with MFA requirements
|
|
209
|
+
4. **Audit Access**: Regularly review CloudTrail logs for deployment activities
|
|
210
|
+
|
|
211
|
+
## Updating the Stack
|
|
212
|
+
|
|
213
|
+
To update permissions or parameters:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
aws cloudformation update-stack \
|
|
217
|
+
--stack-name frigg-deployment-iam \
|
|
218
|
+
--template-body file://frigg-deployment-iam-stack.yaml \
|
|
219
|
+
--capabilities CAPABILITY_NAMED_IAM \
|
|
220
|
+
--parameter-overrides \
|
|
221
|
+
EnableVPCSupport=false # Example: disable VPC support
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Deleting the Stack
|
|
225
|
+
|
|
226
|
+
⚠️ **Warning**: This will delete the IAM user and all associated access keys!
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# First, delete any access keys manually
|
|
230
|
+
aws iam delete-access-key \
|
|
231
|
+
--user-name frigg-deployment-user \
|
|
232
|
+
--access-key-id YOUR_ACCESS_KEY_ID
|
|
233
|
+
|
|
234
|
+
# Then delete the stack
|
|
235
|
+
aws cloudformation delete-stack --stack-name frigg-deployment-iam
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Troubleshooting
|
|
239
|
+
|
|
240
|
+
### Permission Denied Errors
|
|
241
|
+
|
|
242
|
+
If you encounter permission errors during deployment:
|
|
243
|
+
|
|
244
|
+
1. Check that the IAM user name follows the pattern `*frigg*`
|
|
245
|
+
2. Ensure your resources (Lambda functions, stacks) include "frigg" in their names
|
|
246
|
+
3. Verify the correct AWS region is configured
|
|
247
|
+
|
|
248
|
+
### Discovery Failures
|
|
249
|
+
|
|
250
|
+
If AWS resource discovery fails during build:
|
|
251
|
+
|
|
252
|
+
1. Verify the deployment user has the discovery permissions
|
|
253
|
+
2. Check that default VPC and subnets exist in your region
|
|
254
|
+
3. Review build logs for specific error messages
|
|
255
|
+
|
|
256
|
+
### Stack Creation Failures
|
|
257
|
+
|
|
258
|
+
Common issues:
|
|
259
|
+
|
|
260
|
+
- **CAPABILITY_NAMED_IAM required**: Add `--capabilities CAPABILITY_NAMED_IAM` to deploy command
|
|
261
|
+
- **User already exists**: Choose a different `DeploymentUserName` parameter
|
|
262
|
+
- **Policy limit exceeded**: AWS accounts have limits on managed policies; consider consolidating
|
|
263
|
+
|
|
264
|
+
## Additional Resources
|
|
265
|
+
|
|
266
|
+
- [AWS IAM Best Practices](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html)
|
|
267
|
+
- [Frigg Documentation](https://github.com/friggframework/frigg)
|
|
268
|
+
- [AWS CloudFormation Documentation](https://docs.aws.amazon.com/cloudformation/)
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# Generate IAM Command
|
|
2
|
+
|
|
3
|
+
The `frigg generate-iam` command creates a customized IAM CloudFormation template based on your specific Frigg application configuration.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Instead of using a generic IAM policy that includes all possible permissions, this command analyzes your AppDefinition and generates an IAM stack that only includes the permissions your application actually needs.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx frigg generate-iam [options]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Options
|
|
16
|
+
|
|
17
|
+
- `-o, --output <path>` - Output directory (default: `backend/infrastructure`)
|
|
18
|
+
- `-u, --user <name>` - Deployment user name (default: `frigg-deployment-user`)
|
|
19
|
+
- `-s, --stack-name <name>` - CloudFormation stack name (default: `frigg-deployment-iam`)
|
|
20
|
+
- `-v, --verbose` - Enable verbose output
|
|
21
|
+
|
|
22
|
+
### Examples
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Generate with defaults
|
|
26
|
+
npx frigg generate-iam
|
|
27
|
+
|
|
28
|
+
# Specify custom output directory
|
|
29
|
+
npx frigg generate-iam --output ./aws-infrastructure
|
|
30
|
+
|
|
31
|
+
# Custom user name and stack name
|
|
32
|
+
npx frigg generate-iam --user my-app-deployer --stack-name my-app-iam
|
|
33
|
+
|
|
34
|
+
# Verbose output
|
|
35
|
+
npx frigg generate-iam --verbose
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## What Gets Generated
|
|
39
|
+
|
|
40
|
+
The command analyzes your `backend/index.js` AppDefinition and generates IAM policies based on:
|
|
41
|
+
|
|
42
|
+
### Always Included (Core Features)
|
|
43
|
+
|
|
44
|
+
- **CloudFormation** - Stack management permissions
|
|
45
|
+
- **Lambda** - Function deployment and management
|
|
46
|
+
- **IAM** - Role creation and management for Lambda functions
|
|
47
|
+
- **S3** - Deployment bucket access
|
|
48
|
+
- **SQS/SNS** - Messaging services
|
|
49
|
+
- **CloudWatch/Logs** - Monitoring and logging
|
|
50
|
+
- **API Gateway** - REST API management
|
|
51
|
+
|
|
52
|
+
### Conditionally Included (Based on AppDefinition)
|
|
53
|
+
|
|
54
|
+
#### VPC Support (`vpc.enable: true`)
|
|
55
|
+
|
|
56
|
+
- VPC endpoint creation and management
|
|
57
|
+
- NAT Gateway creation and management
|
|
58
|
+
- Route table and security group management
|
|
59
|
+
- Elastic IP allocation
|
|
60
|
+
|
|
61
|
+
#### KMS Encryption (`encryption.fieldLevelEncryptionMethod: 'kms'`)
|
|
62
|
+
|
|
63
|
+
- KMS key usage for Lambda and S3
|
|
64
|
+
- Data encryption and decryption permissions
|
|
65
|
+
|
|
66
|
+
#### SSM Parameter Store (`ssm.enable: true`)
|
|
67
|
+
|
|
68
|
+
- Parameter retrieval permissions
|
|
69
|
+
- Scoped to parameters containing "frigg" in the path
|
|
70
|
+
|
|
71
|
+
#### WebSocket Support (`websockets.enable: true`)
|
|
72
|
+
|
|
73
|
+
- Currently included in core permissions
|
|
74
|
+
- API Gateway WebSocket management
|
|
75
|
+
|
|
76
|
+
## Sample AppDefinition Analysis
|
|
77
|
+
|
|
78
|
+
Given this AppDefinition:
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
const appDefinition = {
|
|
82
|
+
name: 'my-integration-app',
|
|
83
|
+
integrations: [AsanaIntegration, SlackIntegration],
|
|
84
|
+
vpc: {
|
|
85
|
+
enable: true,
|
|
86
|
+
},
|
|
87
|
+
encryption: {
|
|
88
|
+
fieldLevelEncryptionMethod: 'kms',
|
|
89
|
+
},
|
|
90
|
+
ssm: {
|
|
91
|
+
enable: false,
|
|
92
|
+
},
|
|
93
|
+
websockets: {
|
|
94
|
+
enable: true,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The command will generate:
|
|
100
|
+
|
|
101
|
+
- ✅ Core deployment permissions
|
|
102
|
+
- ✅ VPC management permissions
|
|
103
|
+
- ✅ KMS encryption permissions
|
|
104
|
+
- ❌ SSM Parameter Store permissions (disabled)
|
|
105
|
+
- ✅ WebSocket permissions (via core)
|
|
106
|
+
|
|
107
|
+
## Generated File Structure
|
|
108
|
+
|
|
109
|
+
The command creates:
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
backend/infrastructure/
|
|
113
|
+
├── frigg-deployment-iam.yaml # Main CloudFormation template
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Security Benefits
|
|
117
|
+
|
|
118
|
+
### Principle of Least Privilege
|
|
119
|
+
|
|
120
|
+
- Only includes permissions your app actually uses
|
|
121
|
+
- Scoped resource patterns (e.g., only resources containing "frigg")
|
|
122
|
+
- No unnecessary cloud service permissions
|
|
123
|
+
|
|
124
|
+
### Resource Scoping
|
|
125
|
+
|
|
126
|
+
All permissions are scoped to resources following naming patterns:
|
|
127
|
+
|
|
128
|
+
- `*frigg*` - General Frigg resources
|
|
129
|
+
- `*serverless*` - Deployment buckets
|
|
130
|
+
- `internal-error-queue-*` - Error handling queues
|
|
131
|
+
|
|
132
|
+
### Conditional Policies
|
|
133
|
+
|
|
134
|
+
Feature-specific policies are only created when:
|
|
135
|
+
|
|
136
|
+
- The feature is enabled in your AppDefinition
|
|
137
|
+
- CloudFormation conditions control policy attachment
|
|
138
|
+
|
|
139
|
+
## Deployment Workflow
|
|
140
|
+
|
|
141
|
+
After generating the template:
|
|
142
|
+
|
|
143
|
+
### 1. Deploy the Stack
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
aws cloudformation deploy \
|
|
147
|
+
--template-file backend/infrastructure/frigg-deployment-iam.yaml \
|
|
148
|
+
--stack-name frigg-deployment-iam \
|
|
149
|
+
--capabilities CAPABILITY_NAMED_IAM \
|
|
150
|
+
--parameter-overrides DeploymentUserName=frigg-deployment-user
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 2. Retrieve Access Key
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
aws cloudformation describe-stacks \
|
|
157
|
+
--stack-name frigg-deployment-iam \
|
|
158
|
+
--query 'Stacks[0].Outputs[?OutputKey==`AccessKeyId`].OutputValue' \
|
|
159
|
+
--output text
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 3. Get Secret Access Key
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
aws secretsmanager get-secret-value \
|
|
166
|
+
--secret-id frigg-deployment-credentials \
|
|
167
|
+
--query SecretString \
|
|
168
|
+
--output text | jq -r .SecretAccessKey
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 4. Configure CI/CD
|
|
172
|
+
|
|
173
|
+
Add the credentials to your deployment environment:
|
|
174
|
+
|
|
175
|
+
- GitHub Actions: Repository secrets
|
|
176
|
+
- GitLab CI: Environment variables
|
|
177
|
+
- Jenkins: Credentials manager
|
|
178
|
+
- Local: AWS credentials file
|
|
179
|
+
|
|
180
|
+
## Troubleshooting
|
|
181
|
+
|
|
182
|
+
### Command Not Found
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Install dependencies
|
|
186
|
+
npm install
|
|
187
|
+
|
|
188
|
+
# Ensure you're in a Frigg project
|
|
189
|
+
ls backend/index.js
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### No AppDefinition Found
|
|
193
|
+
|
|
194
|
+
- Ensure `backend/index.js` exports a `Definition` object
|
|
195
|
+
- Check that the Definition follows the correct structure
|
|
196
|
+
|
|
197
|
+
### Permission Errors During Deployment
|
|
198
|
+
|
|
199
|
+
- Ensure your AWS CLI is configured with admin permissions
|
|
200
|
+
- Add `--capabilities CAPABILITY_NAMED_IAM` to deployment commands
|
|
201
|
+
|
|
202
|
+
### Generated Policy Too Restrictive
|
|
203
|
+
|
|
204
|
+
- Check that your resources follow naming conventions (contain "frigg")
|
|
205
|
+
- Enable additional features in your AppDefinition if needed
|
|
206
|
+
- Review the generated template for resource patterns
|
|
207
|
+
|
|
208
|
+
## Comparison with Generic Template
|
|
209
|
+
|
|
210
|
+
| Aspect | Generic Template | Generated Template |
|
|
211
|
+
| --------------- | ---------------- | --------------------- |
|
|
212
|
+
| Size | ~15KB | ~8-12KB (varies) |
|
|
213
|
+
| Permissions | All features | Only enabled features |
|
|
214
|
+
| Security | Broad access | Scoped access |
|
|
215
|
+
| Maintenance | Manual updates | Auto-generated |
|
|
216
|
+
| Deployment Risk | Over-privileged | Least privilege |
|
|
217
|
+
|
|
218
|
+
## Integration with Development Workflow
|
|
219
|
+
|
|
220
|
+
### Local Development
|
|
221
|
+
|
|
222
|
+
1. Update AppDefinition
|
|
223
|
+
2. Run `npx frigg generate-iam`
|
|
224
|
+
3. Deploy updated IAM stack
|
|
225
|
+
4. Test deployment with new permissions
|
|
226
|
+
|
|
227
|
+
### CI/CD Pipeline
|
|
228
|
+
|
|
229
|
+
```yaml
|
|
230
|
+
# GitHub Actions example
|
|
231
|
+
- name: Generate IAM Template
|
|
232
|
+
run: npx frigg generate-iam
|
|
233
|
+
|
|
234
|
+
- name: Deploy IAM Stack
|
|
235
|
+
run: |
|
|
236
|
+
aws cloudformation deploy \
|
|
237
|
+
--template-file backend/infrastructure/frigg-deployment-iam.yaml \
|
|
238
|
+
--stack-name ${{ env.STACK_NAME }} \
|
|
239
|
+
--capabilities CAPABILITY_NAMED_IAM
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Version Control
|
|
243
|
+
|
|
244
|
+
- Commit generated templates to version control
|
|
245
|
+
- Review changes in pull requests
|
|
246
|
+
- Track permission changes over time
|
|
247
|
+
|
|
248
|
+
## Best Practices
|
|
249
|
+
|
|
250
|
+
1. **Regenerate After Changes** - Run the command whenever you modify your AppDefinition
|
|
251
|
+
2. **Review Generated Templates** - Check the generated YAML before deployment
|
|
252
|
+
3. **Test Deployments** - Verify your app can deploy with the generated permissions
|
|
253
|
+
4. **Environment Separation** - Use different stack names for dev/staging/prod
|
|
254
|
+
5. **Regular Audits** - Periodically review and minimize permissions
|
|
255
|
+
|
|
256
|
+
## Advanced Usage
|
|
257
|
+
|
|
258
|
+
### Custom Parameter Values
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
# Enable all features regardless of AppDefinition
|
|
262
|
+
npx frigg generate-iam --verbose
|
|
263
|
+
|
|
264
|
+
# Then manually edit the generated template to set:
|
|
265
|
+
# EnableVPCSupport: true
|
|
266
|
+
# EnableKMSSupport: true
|
|
267
|
+
# EnableSSMSupport: true
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Multiple Environments
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
# Generate for different environments
|
|
274
|
+
npx frigg generate-iam --stack-name my-app-dev-iam --output ./aws/dev
|
|
275
|
+
npx frigg generate-iam --stack-name my-app-prod-iam --output ./aws/prod
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
This command helps you maintain secure, minimal IAM policies that evolve with your application requirements.
|