@friggframework/devtools 2.0.0-next.39 → 2.0.0-next.40
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/infrastructure/README.md +19 -8
- package/infrastructure/aws-discovery.js +951 -345
- package/infrastructure/aws-discovery.test.js +1031 -184
- package/infrastructure/build-time-discovery.test.js +3 -0
- package/infrastructure/iam-generator.js +46 -0
- package/infrastructure/iam-generator.test.js +7 -4
- package/infrastructure/serverless-template.js +1096 -813
- package/infrastructure/serverless-template.test.js +1036 -21
- package/package.json +8 -6
- package/infrastructure/AWS-DISCOVERY-TROUBLESHOOTING.md +0 -245
- package/infrastructure/AWS-IAM-CREDENTIAL-NEEDS.md +0 -627
- package/infrastructure/README-TESTING.md +0 -332
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/devtools",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0-next.
|
|
4
|
+
"version": "2.0.0-next.40",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@aws-sdk/client-ec2": "^3.835.0",
|
|
7
7
|
"@aws-sdk/client-kms": "^3.835.0",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"@babel/eslint-parser": "^7.18.9",
|
|
10
10
|
"@babel/parser": "^7.25.3",
|
|
11
11
|
"@babel/traverse": "^7.25.3",
|
|
12
|
-
"@friggframework/schemas": "2.0.0-next.
|
|
13
|
-
"@friggframework/test": "2.0.0-next.
|
|
12
|
+
"@friggframework/schemas": "2.0.0-next.40",
|
|
13
|
+
"@friggframework/test": "2.0.0-next.40",
|
|
14
14
|
"@hapi/boom": "^10.0.1",
|
|
15
15
|
"@inquirer/prompts": "^5.3.8",
|
|
16
16
|
"axios": "^1.7.2",
|
|
@@ -32,8 +32,10 @@
|
|
|
32
32
|
"serverless-http": "^2.7.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@friggframework/eslint-config": "2.0.0-next.
|
|
36
|
-
"@friggframework/prettier-config": "2.0.0-next.
|
|
35
|
+
"@friggframework/eslint-config": "2.0.0-next.40",
|
|
36
|
+
"@friggframework/prettier-config": "2.0.0-next.40",
|
|
37
|
+
"aws-sdk-client-mock": "^4.1.0",
|
|
38
|
+
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
37
39
|
"jest": "^30.1.3",
|
|
38
40
|
"prettier": "^2.7.1",
|
|
39
41
|
"serverless": "3.39.0",
|
|
@@ -66,5 +68,5 @@
|
|
|
66
68
|
"publishConfig": {
|
|
67
69
|
"access": "public"
|
|
68
70
|
},
|
|
69
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "088c50c6e1e37a6d42be05af49349b70ae94ee31"
|
|
70
72
|
}
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
# AWS Discovery Troubleshooting Guide
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
AWS Discovery automatically finds your default AWS resources (VPC, subnets, security groups, KMS keys) during the build process. This eliminates the need to manually specify resource IDs in your configuration.
|
|
6
|
-
|
|
7
|
-
## When AWS Discovery Runs
|
|
8
|
-
|
|
9
|
-
AWS Discovery runs automatically during `frigg build` and `frigg deploy` when your AppDefinition includes:
|
|
10
|
-
|
|
11
|
-
- `vpc.enable: true` - VPC support
|
|
12
|
-
- `encryption.fieldLevelEncryptionMethod: 'kms'` - KMS encryption
|
|
13
|
-
- `ssm.enable: true` - SSM Parameter Store
|
|
14
|
-
|
|
15
|
-
## Fail-Fast Behavior
|
|
16
|
-
|
|
17
|
-
⚠️ **Important:** If you enable these features, discovery **must succeed**. The build will fail if:
|
|
18
|
-
- AWS credentials are missing or invalid
|
|
19
|
-
- Required AWS permissions are not granted
|
|
20
|
-
- No VPC/subnets exist in your region
|
|
21
|
-
- Discovery times out or encounters errors
|
|
22
|
-
|
|
23
|
-
This prevents deployments with incorrect or missing AWS resources, which could cause security issues or deployment failures.
|
|
24
|
-
|
|
25
|
-
## Common Issues
|
|
26
|
-
|
|
27
|
-
### 1. "Variables resolution errored" - Environment Variables Not Found
|
|
28
|
-
|
|
29
|
-
**Error:**
|
|
30
|
-
```
|
|
31
|
-
Cannot resolve variable at "provider.vpc.securityGroupIds.0": Value not found at "env" source
|
|
32
|
-
Cannot resolve variable at "provider.vpc.subnetIds.0": Value not found at "env" source
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
**Cause:** AWS discovery didn't run or failed to set environment variables.
|
|
36
|
-
|
|
37
|
-
**Solutions:**
|
|
38
|
-
|
|
39
|
-
#### Option A: Run Discovery Manually
|
|
40
|
-
```bash
|
|
41
|
-
# Run discovery before building
|
|
42
|
-
node node_modules/@friggframework/devtools/infrastructure/run-discovery.js
|
|
43
|
-
|
|
44
|
-
# Then build
|
|
45
|
-
npx frigg build
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
#### Option B: Check Prerequisites
|
|
49
|
-
1. **AWS Credentials:** Ensure AWS CLI is configured
|
|
50
|
-
```bash
|
|
51
|
-
aws configure list
|
|
52
|
-
aws sts get-caller-identity
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
2. **IAM Permissions:** User needs discovery permissions (see [AWS-IAM-CREDENTIAL-NEEDS.md](./AWS-IAM-CREDENTIAL-NEEDS.md))
|
|
56
|
-
- `sts:GetCallerIdentity`
|
|
57
|
-
- `ec2:DescribeVpcs`
|
|
58
|
-
- `ec2:DescribeSubnets`
|
|
59
|
-
- `ec2:DescribeSecurityGroups`
|
|
60
|
-
- `ec2:DescribeRouteTables`
|
|
61
|
-
- `kms:ListKeys`
|
|
62
|
-
- `kms:DescribeKey`
|
|
63
|
-
|
|
64
|
-
3. **Default VPC:** Ensure you have a VPC in your AWS region
|
|
65
|
-
```bash
|
|
66
|
-
aws ec2 describe-vpcs --region us-east-1
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### 2. AWS SDK Not Installed
|
|
70
|
-
|
|
71
|
-
**Error:**
|
|
72
|
-
```bash
|
|
73
|
-
🚨 AWS SDK not installed!
|
|
74
|
-
Cannot find module '@aws-sdk/client-ec2'
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
**Cause:** AWS SDK dependencies are only installed when needed to keep bundle size minimal.
|
|
78
|
-
|
|
79
|
-
**Solution:**
|
|
80
|
-
```bash
|
|
81
|
-
# Install required AWS SDK packages
|
|
82
|
-
npm install @aws-sdk/client-ec2 @aws-sdk/client-kms @aws-sdk/client-sts
|
|
83
|
-
|
|
84
|
-
# Then run discovery
|
|
85
|
-
npx frigg build
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
**Note:** AWS SDK is optional - only install if you use VPC/KMS/SSM features.
|
|
89
|
-
|
|
90
|
-
### 3. No Default VPC Found
|
|
91
|
-
|
|
92
|
-
**Error:**
|
|
93
|
-
```
|
|
94
|
-
No VPC found in the account
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
**Cause:** Your AWS account doesn't have a default VPC or any VPCs in the current region.
|
|
98
|
-
|
|
99
|
-
**Solutions:**
|
|
100
|
-
|
|
101
|
-
#### Option A: Create Default VPC
|
|
102
|
-
```bash
|
|
103
|
-
aws ec2 create-default-vpc --region us-east-1
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
#### Option B: Disable VPC in AppDefinition
|
|
107
|
-
```javascript
|
|
108
|
-
// backend/index.js
|
|
109
|
-
const appDefinition = {
|
|
110
|
-
// ... other config
|
|
111
|
-
vpc: {
|
|
112
|
-
enable: false // Disable VPC support
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### 4. Permission Denied During Discovery
|
|
118
|
-
|
|
119
|
-
**Error:**
|
|
120
|
-
```
|
|
121
|
-
User: arn:aws:iam::123456789012:user/my-user is not authorized to perform: ec2:DescribeVpcs
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
**Cause:** IAM user lacks discovery permissions.
|
|
125
|
-
|
|
126
|
-
**Solution:**
|
|
127
|
-
1. Update IAM policy with discovery permissions
|
|
128
|
-
2. Or generate a custom IAM stack:
|
|
129
|
-
```bash
|
|
130
|
-
npx frigg generate-iam
|
|
131
|
-
aws cloudformation deploy --template-file backend/infrastructure/frigg-deployment-iam.yaml --stack-name frigg-deployment-iam --capabilities CAPABILITY_NAMED_IAM
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### 5. Region Configuration Issues
|
|
135
|
-
|
|
136
|
-
**Error:**
|
|
137
|
-
```
|
|
138
|
-
No subnets found in VPC vpc-123456789
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
**Cause:** AWS discovery is looking in the wrong region or region has no subnets.
|
|
142
|
-
|
|
143
|
-
**Solutions:**
|
|
144
|
-
|
|
145
|
-
#### Option A: Set AWS Region
|
|
146
|
-
```bash
|
|
147
|
-
export AWS_REGION=us-east-1
|
|
148
|
-
npx frigg build
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
#### Option B: Check Current Region
|
|
152
|
-
```bash
|
|
153
|
-
aws configure get region
|
|
154
|
-
aws ec2 describe-availability-zones --query 'AvailabilityZones[0].RegionName'
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## Manual Override
|
|
158
|
-
|
|
159
|
-
If AWS discovery continues to fail, you can manually set environment variables:
|
|
160
|
-
|
|
161
|
-
```bash
|
|
162
|
-
# Find your actual resource IDs
|
|
163
|
-
aws ec2 describe-vpcs --query 'Vpcs[0].VpcId' --output text
|
|
164
|
-
aws ec2 describe-subnets --filters "Name=vpc-id,Values=vpc-12345678" --query 'Subnets[0:2].SubnetId' --output text
|
|
165
|
-
|
|
166
|
-
# Set before building
|
|
167
|
-
export AWS_DISCOVERY_VPC_ID=vpc-12345678
|
|
168
|
-
export AWS_DISCOVERY_SECURITY_GROUP_ID=sg-12345678
|
|
169
|
-
export AWS_DISCOVERY_SUBNET_ID_1=subnet-12345678
|
|
170
|
-
export AWS_DISCOVERY_SUBNET_ID_2=subnet-87654321
|
|
171
|
-
export AWS_DISCOVERY_PUBLIC_SUBNET_ID=subnet-abcdef12
|
|
172
|
-
export AWS_DISCOVERY_ROUTE_TABLE_ID=rtb-12345678
|
|
173
|
-
export AWS_DISCOVERY_KMS_KEY_ID=arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012
|
|
174
|
-
|
|
175
|
-
npx frigg build
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
**⚠️ Important:** Use real AWS resource IDs, not placeholder values. Fake IDs will cause deployment failures.
|
|
179
|
-
|
|
180
|
-
## Debugging Discovery
|
|
181
|
-
|
|
182
|
-
### Enable Verbose Logging
|
|
183
|
-
```bash
|
|
184
|
-
npx frigg build --verbose
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### Test Discovery Standalone
|
|
188
|
-
```bash
|
|
189
|
-
# Test discovery without building
|
|
190
|
-
node node_modules/@friggframework/devtools/infrastructure/run-discovery.js
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Check Environment Variables
|
|
194
|
-
```bash
|
|
195
|
-
# After running discovery
|
|
196
|
-
printenv | grep AWS_DISCOVERY
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## Recovery Steps
|
|
200
|
-
|
|
201
|
-
If you're stuck, try this recovery process:
|
|
202
|
-
|
|
203
|
-
1. **Verify AWS Setup**
|
|
204
|
-
```bash
|
|
205
|
-
aws sts get-caller-identity
|
|
206
|
-
aws ec2 describe-vpcs --region us-east-1
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
2. **Check App Definition**
|
|
210
|
-
```bash
|
|
211
|
-
# Ensure your backend/index.js exports Definition correctly
|
|
212
|
-
node -e "console.log(require('./backend/index.js').Definition)"
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
3. **Run Discovery Manually**
|
|
216
|
-
```bash
|
|
217
|
-
node node_modules/@friggframework/devtools/infrastructure/run-discovery.js
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
4. **Disable Features Temporarily**
|
|
221
|
-
```javascript
|
|
222
|
-
// backend/index.js - temporarily disable problematic features
|
|
223
|
-
const appDefinition = {
|
|
224
|
-
vpc: { enable: false },
|
|
225
|
-
encryption: { fieldLevelEncryptionMethod: 'aes' },
|
|
226
|
-
ssm: { enable: false }
|
|
227
|
-
};
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
5. **Build and Test**
|
|
231
|
-
```bash
|
|
232
|
-
npx frigg build
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
## Getting Help
|
|
236
|
-
|
|
237
|
-
If discovery continues to fail:
|
|
238
|
-
|
|
239
|
-
1. **Check logs** for specific error messages
|
|
240
|
-
2. **Verify IAM permissions** using the generated IAM stack
|
|
241
|
-
3. **Test AWS CLI access** in your target region
|
|
242
|
-
4. **Review AppDefinition** for correct feature flags
|
|
243
|
-
5. **Try fallback values** as a temporary workaround
|
|
244
|
-
|
|
245
|
-
The discovery system is designed to be resilient, but AWS environment differences can cause issues. Most problems are related to IAM permissions or missing AWS resources in the target region.
|