@friggframework/devtools 2.0.0-next.33 → 2.0.0-next.35
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/deploy-command/index.js +4 -3
- package/infrastructure/AWS-IAM-CREDENTIAL-NEEDS.md +442 -411
- package/infrastructure/GENERATE-IAM-DOCS.md +91 -66
- package/infrastructure/frigg-deployment-iam-stack.yaml +22 -0
- package/infrastructure/iam-generator.js +210 -229
- package/infrastructure/serverless-template.js +426 -243
- package/package.json +6 -6
|
@@ -14,10 +14,10 @@ npx frigg generate-iam [options]
|
|
|
14
14
|
|
|
15
15
|
### Options
|
|
16
16
|
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
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
21
|
|
|
22
22
|
### Examples
|
|
23
23
|
|
|
@@ -40,33 +40,38 @@ npx frigg generate-iam --verbose
|
|
|
40
40
|
The command analyzes your `backend/index.js` AppDefinition and generates IAM policies based on:
|
|
41
41
|
|
|
42
42
|
### Always Included (Core Features)
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
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
|
|
50
51
|
|
|
51
52
|
### Conditionally Included (Based on AppDefinition)
|
|
52
53
|
|
|
53
54
|
#### VPC Support (`vpc.enable: true`)
|
|
54
|
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
55
|
+
|
|
56
|
+
- VPC endpoint creation and management
|
|
57
|
+
- NAT Gateway creation and management
|
|
58
|
+
- Route table and security group management
|
|
59
|
+
- Elastic IP allocation
|
|
58
60
|
|
|
59
61
|
#### KMS Encryption (`encryption.useDefaultKMSForFieldLevelEncryption: true`)
|
|
60
|
-
|
|
61
|
-
-
|
|
62
|
+
|
|
63
|
+
- KMS key usage for Lambda and S3
|
|
64
|
+
- Data encryption and decryption permissions
|
|
62
65
|
|
|
63
66
|
#### SSM Parameter Store (`ssm.enable: true`)
|
|
64
|
-
|
|
65
|
-
-
|
|
67
|
+
|
|
68
|
+
- Parameter retrieval permissions
|
|
69
|
+
- Scoped to parameters containing "frigg" in the path
|
|
66
70
|
|
|
67
71
|
#### WebSocket Support (`websockets.enable: true`)
|
|
68
|
-
|
|
69
|
-
-
|
|
72
|
+
|
|
73
|
+
- Currently included in core permissions
|
|
74
|
+
- API Gateway WebSocket management
|
|
70
75
|
|
|
71
76
|
## Sample AppDefinition Analysis
|
|
72
77
|
|
|
@@ -77,26 +82,27 @@ const appDefinition = {
|
|
|
77
82
|
name: 'my-integration-app',
|
|
78
83
|
integrations: [AsanaIntegration, SlackIntegration],
|
|
79
84
|
vpc: {
|
|
80
|
-
enable: true
|
|
85
|
+
enable: true,
|
|
81
86
|
},
|
|
82
87
|
encryption: {
|
|
83
|
-
useDefaultKMSForFieldLevelEncryption: true
|
|
88
|
+
useDefaultKMSForFieldLevelEncryption: true,
|
|
84
89
|
},
|
|
85
90
|
ssm: {
|
|
86
|
-
enable: false
|
|
91
|
+
enable: false,
|
|
87
92
|
},
|
|
88
93
|
websockets: {
|
|
89
|
-
enable: true
|
|
90
|
-
}
|
|
94
|
+
enable: true,
|
|
95
|
+
},
|
|
91
96
|
};
|
|
92
97
|
```
|
|
93
98
|
|
|
94
99
|
The command will generate:
|
|
95
|
-
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
-
|
|
100
|
+
|
|
101
|
+
- ✅ Core deployment permissions
|
|
102
|
+
- ✅ VPC management permissions
|
|
103
|
+
- ✅ KMS encryption permissions
|
|
104
|
+
- ❌ SSM Parameter Store permissions (disabled)
|
|
105
|
+
- ✅ WebSocket permissions (via core)
|
|
100
106
|
|
|
101
107
|
## Generated File Structure
|
|
102
108
|
|
|
@@ -110,26 +116,32 @@ backend/infrastructure/
|
|
|
110
116
|
## Security Benefits
|
|
111
117
|
|
|
112
118
|
### Principle of Least Privilege
|
|
113
|
-
|
|
114
|
-
-
|
|
115
|
-
-
|
|
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
|
|
116
123
|
|
|
117
124
|
### Resource Scoping
|
|
125
|
+
|
|
118
126
|
All permissions are scoped to resources following naming patterns:
|
|
119
|
-
|
|
120
|
-
-
|
|
121
|
-
-
|
|
127
|
+
|
|
128
|
+
- `*frigg*` - General Frigg resources
|
|
129
|
+
- `*serverless*` - Deployment buckets
|
|
130
|
+
- `internal-error-queue-*` - Error handling queues
|
|
122
131
|
|
|
123
132
|
### Conditional Policies
|
|
133
|
+
|
|
124
134
|
Feature-specific policies are only created when:
|
|
125
|
-
|
|
126
|
-
-
|
|
135
|
+
|
|
136
|
+
- The feature is enabled in your AppDefinition
|
|
137
|
+
- CloudFormation conditions control policy attachment
|
|
127
138
|
|
|
128
139
|
## Deployment Workflow
|
|
129
140
|
|
|
130
141
|
After generating the template:
|
|
131
142
|
|
|
132
143
|
### 1. Deploy the Stack
|
|
144
|
+
|
|
133
145
|
```bash
|
|
134
146
|
aws cloudformation deploy \
|
|
135
147
|
--template-file backend/infrastructure/frigg-deployment-iam.yaml \
|
|
@@ -139,6 +151,7 @@ aws cloudformation deploy \
|
|
|
139
151
|
```
|
|
140
152
|
|
|
141
153
|
### 2. Retrieve Access Key
|
|
154
|
+
|
|
142
155
|
```bash
|
|
143
156
|
aws cloudformation describe-stacks \
|
|
144
157
|
--stack-name frigg-deployment-iam \
|
|
@@ -147,6 +160,7 @@ aws cloudformation describe-stacks \
|
|
|
147
160
|
```
|
|
148
161
|
|
|
149
162
|
### 3. Get Secret Access Key
|
|
163
|
+
|
|
150
164
|
```bash
|
|
151
165
|
aws secretsmanager get-secret-value \
|
|
152
166
|
--secret-id frigg-deployment-credentials \
|
|
@@ -155,15 +169,18 @@ aws secretsmanager get-secret-value \
|
|
|
155
169
|
```
|
|
156
170
|
|
|
157
171
|
### 4. Configure CI/CD
|
|
172
|
+
|
|
158
173
|
Add the credentials to your deployment environment:
|
|
159
|
-
|
|
160
|
-
-
|
|
161
|
-
-
|
|
162
|
-
-
|
|
174
|
+
|
|
175
|
+
- GitHub Actions: Repository secrets
|
|
176
|
+
- GitLab CI: Environment variables
|
|
177
|
+
- Jenkins: Credentials manager
|
|
178
|
+
- Local: AWS credentials file
|
|
163
179
|
|
|
164
180
|
## Troubleshooting
|
|
165
181
|
|
|
166
182
|
### Command Not Found
|
|
183
|
+
|
|
167
184
|
```bash
|
|
168
185
|
# Install dependencies
|
|
169
186
|
npm install
|
|
@@ -173,37 +190,42 @@ ls backend/index.js
|
|
|
173
190
|
```
|
|
174
191
|
|
|
175
192
|
### No AppDefinition Found
|
|
176
|
-
|
|
177
|
-
-
|
|
193
|
+
|
|
194
|
+
- Ensure `backend/index.js` exports a `Definition` object
|
|
195
|
+
- Check that the Definition follows the correct structure
|
|
178
196
|
|
|
179
197
|
### Permission Errors During Deployment
|
|
180
|
-
|
|
181
|
-
-
|
|
198
|
+
|
|
199
|
+
- Ensure your AWS CLI is configured with admin permissions
|
|
200
|
+
- Add `--capabilities CAPABILITY_NAMED_IAM` to deployment commands
|
|
182
201
|
|
|
183
202
|
### Generated Policy Too Restrictive
|
|
184
|
-
|
|
185
|
-
-
|
|
186
|
-
-
|
|
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
|
|
187
207
|
|
|
188
208
|
## Comparison with Generic Template
|
|
189
209
|
|
|
190
|
-
| Aspect
|
|
191
|
-
|
|
192
|
-
| Size
|
|
193
|
-
| Permissions
|
|
194
|
-
| Security
|
|
195
|
-
| Maintenance
|
|
196
|
-
| Deployment Risk | Over-privileged
|
|
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 |
|
|
197
217
|
|
|
198
218
|
## Integration with Development Workflow
|
|
199
219
|
|
|
200
220
|
### Local Development
|
|
221
|
+
|
|
201
222
|
1. Update AppDefinition
|
|
202
223
|
2. Run `npx frigg generate-iam`
|
|
203
224
|
3. Deploy updated IAM stack
|
|
204
225
|
4. Test deployment with new permissions
|
|
205
226
|
|
|
206
227
|
### CI/CD Pipeline
|
|
228
|
+
|
|
207
229
|
```yaml
|
|
208
230
|
# GitHub Actions example
|
|
209
231
|
- name: Generate IAM Template
|
|
@@ -211,16 +233,17 @@ ls backend/index.js
|
|
|
211
233
|
|
|
212
234
|
- name: Deploy IAM Stack
|
|
213
235
|
run: |
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
236
|
+
aws cloudformation deploy \
|
|
237
|
+
--template-file backend/infrastructure/frigg-deployment-iam.yaml \
|
|
238
|
+
--stack-name ${{ env.STACK_NAME }} \
|
|
239
|
+
--capabilities CAPABILITY_NAMED_IAM
|
|
218
240
|
```
|
|
219
241
|
|
|
220
242
|
### Version Control
|
|
221
|
-
|
|
222
|
-
-
|
|
223
|
-
-
|
|
243
|
+
|
|
244
|
+
- Commit generated templates to version control
|
|
245
|
+
- Review changes in pull requests
|
|
246
|
+
- Track permission changes over time
|
|
224
247
|
|
|
225
248
|
## Best Practices
|
|
226
249
|
|
|
@@ -233,21 +256,23 @@ ls backend/index.js
|
|
|
233
256
|
## Advanced Usage
|
|
234
257
|
|
|
235
258
|
### Custom Parameter Values
|
|
259
|
+
|
|
236
260
|
```bash
|
|
237
261
|
# Enable all features regardless of AppDefinition
|
|
238
262
|
npx frigg generate-iam --verbose
|
|
239
263
|
|
|
240
264
|
# Then manually edit the generated template to set:
|
|
241
265
|
# EnableVPCSupport: true
|
|
242
|
-
# EnableKMSSupport: true
|
|
266
|
+
# EnableKMSSupport: true
|
|
243
267
|
# EnableSSMSupport: true
|
|
244
268
|
```
|
|
245
269
|
|
|
246
270
|
### Multiple Environments
|
|
271
|
+
|
|
247
272
|
```bash
|
|
248
273
|
# Generate for different environments
|
|
249
274
|
npx frigg generate-iam --stack-name my-app-dev-iam --output ./aws/dev
|
|
250
275
|
npx frigg generate-iam --stack-name my-app-prod-iam --output ./aws/prod
|
|
251
276
|
```
|
|
252
277
|
|
|
253
|
-
This command helps you maintain secure, minimal IAM policies that evolve with your application requirements.
|
|
278
|
+
This command helps you maintain secure, minimal IAM policies that evolve with your application requirements.
|
|
@@ -257,6 +257,26 @@ Resources:
|
|
|
257
257
|
- 'arn:aws:apigateway:*::/restapis/*'
|
|
258
258
|
- 'arn:aws:apigateway:*::/domainnames'
|
|
259
259
|
- 'arn:aws:apigateway:*::/domainnames/*'
|
|
260
|
+
|
|
261
|
+
# API Gateway v2 permissions
|
|
262
|
+
- Sid: 'FriggAPIGatewayV2'
|
|
263
|
+
Effect: Allow
|
|
264
|
+
Action:
|
|
265
|
+
- 'apigateway:GET'
|
|
266
|
+
- 'apigateway:DELETE'
|
|
267
|
+
- 'apigateway:PATCH'
|
|
268
|
+
- 'apigateway:POST'
|
|
269
|
+
- 'apigateway:PUT'
|
|
270
|
+
Resource:
|
|
271
|
+
- 'arn:aws:apigateway:*::/apis'
|
|
272
|
+
- 'arn:aws:apigateway:*::/apis/*'
|
|
273
|
+
- 'arn:aws:apigateway:*::/apis/*/stages'
|
|
274
|
+
- 'arn:aws:apigateway:*::/apis/*/stages/*'
|
|
275
|
+
- 'arn:aws:apigateway:*::/apis/*/mappings'
|
|
276
|
+
- 'arn:aws:apigateway:*::/apis/*/mappings/*'
|
|
277
|
+
- 'arn:aws:apigateway:*::/domainnames'
|
|
278
|
+
- 'arn:aws:apigateway:*::/domainnames/*'
|
|
279
|
+
- 'arn:aws:apigateway:*::/domainnames/*/apimappings'
|
|
260
280
|
|
|
261
281
|
# VPC-specific permissions
|
|
262
282
|
FriggVPCPolicy:
|
|
@@ -297,6 +317,8 @@ Resources:
|
|
|
297
317
|
- 'ec2:CreateTags'
|
|
298
318
|
- 'ec2:DeleteTags'
|
|
299
319
|
- 'ec2:DescribeTags'
|
|
320
|
+
- 'ec2:DetachInternetGateway'
|
|
321
|
+
- 'ec2:DeleteSubnet'
|
|
300
322
|
Resource: '*'
|
|
301
323
|
|
|
302
324
|
# KMS permissions
|