@friggframework/devtools 2.0.0--canary.490.72cc5dc.0 → 2.0.0--canary.490.56e2519.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,9 +54,10 @@ class VpcResourceResolver extends BaseResourceResolver {
54
54
  /**
55
55
  * Resolve Security Group ownership
56
56
  *
57
- * Special logic: We ALWAYS create our own FriggLambdaSecurityGroup with specific
58
- * rules unless the user explicitly provides external SG IDs. The discovered
59
- * defaultSecurityGroupId is the VPC's default SG, but we need our own Lambda SG.
57
+ * Logic:
58
+ * - If FriggLambdaSecurityGroup exists in stack STACK (keep it)
59
+ * - If default SG discovered from VPC EXTERNAL (use it)
60
+ * - Otherwise → STACK (create FriggLambdaSecurityGroup)
60
61
  *
61
62
  * @param {Object} appDefinition - App definition
62
63
  * @param {Object} discovery - Discovery result
@@ -65,7 +66,7 @@ class VpcResourceResolver extends BaseResourceResolver {
65
66
  resolveSecurityGroup(appDefinition, discovery) {
66
67
  const userIntent = appDefinition.vpc?.ownership?.securityGroup || 'auto';
67
68
 
68
- // Explicit external - only use external SGs if user explicitly provides them
69
+ // Explicit external - use provided SG IDs
69
70
  if (userIntent === 'external') {
70
71
  this.requireExternalIds(
71
72
  appDefinition.vpc?.external?.securityGroupIds,
@@ -77,21 +78,42 @@ class VpcResourceResolver extends BaseResourceResolver {
77
78
  );
78
79
  }
79
80
 
80
- // For stack or auto: check if FriggLambdaSecurityGroup exists in stack
81
- // If it does, reuse it. If not, create it. Never use discovered default SG.
81
+ // Explicit stack - always create FriggLambdaSecurityGroup
82
+ if (userIntent === 'stack') {
83
+ const inStack = this.findInStack('FriggLambdaSecurityGroup', discovery);
84
+ return this.createStackDecision(
85
+ inStack?.physicalId,
86
+ inStack
87
+ ? 'Found FriggLambdaSecurityGroup in CloudFormation stack'
88
+ : 'User specified ownership=stack - will create FriggLambdaSecurityGroup'
89
+ );
90
+ }
91
+
92
+ // Auto mode: Check stack first, then check for discovered default SG
82
93
  const inStack = this.findInStack('FriggLambdaSecurityGroup', discovery);
83
94
 
84
95
  if (inStack) {
85
96
  return this.createStackDecision(
86
97
  inStack.physicalId,
87
- 'Found FriggLambdaSecurityGroup in CloudFormation stack'
98
+ 'Found FriggLambdaSecurityGroup in CloudFormation stack - must keep in template'
99
+ );
100
+ }
101
+
102
+ // Check for discovered default security group (from old canary pattern)
103
+ const structured = discovery._structured || discovery;
104
+ const defaultSgId = structured.defaultSecurityGroupId || discovery.defaultSecurityGroupId;
105
+
106
+ if (defaultSgId) {
107
+ return this.createExternalDecision(
108
+ [defaultSgId],
109
+ 'Found default security group via discovery - will reuse (matches canary behavior)'
88
110
  );
89
111
  }
90
112
 
91
- // Create new FriggLambdaSecurityGroup in stack
113
+ // No SG found anywhere - create new FriggLambdaSecurityGroup
92
114
  return this.createStackDecision(
93
115
  null,
94
- 'No existing FriggLambdaSecurityGroup - will create in stack'
116
+ 'No security group found - will create FriggLambdaSecurityGroup in stack'
95
117
  );
96
118
  }
97
119
 
@@ -169,6 +169,26 @@ class CloudFormationDiscovery {
169
169
  discovered.privateSubnetId2 = subnetAssociations[1].SubnetId;
170
170
  console.log(` ✓ Extracted private subnet 2 from associations: ${subnetAssociations[1].SubnetId}`);
171
171
  }
172
+
173
+ // Query for default security group in the VPC (matches canary behavior)
174
+ if (routeTable.VpcId && !discovered.defaultSecurityGroupId) {
175
+ try {
176
+ const { DescribeSecurityGroupsCommand } = require('@aws-sdk/client-ec2');
177
+ const sgResponse = await ec2.send(new DescribeSecurityGroupsCommand({
178
+ Filters: [
179
+ { Name: 'vpc-id', Values: [routeTable.VpcId] },
180
+ { Name: 'group-name', Values: ['default'] }
181
+ ]
182
+ }));
183
+
184
+ if (sgResponse.SecurityGroups && sgResponse.SecurityGroups.length > 0) {
185
+ discovered.defaultSecurityGroupId = sgResponse.SecurityGroups[0].GroupId;
186
+ console.log(` ✓ Extracted default security group: ${discovered.defaultSecurityGroupId}`);
187
+ }
188
+ } catch (error) {
189
+ console.warn(` ⚠️ Could not query default security group: ${error.message}`);
190
+ }
191
+ }
172
192
  }
173
193
  } catch (error) {
174
194
  console.warn(` ⚠️ Could not query route table for external references: ${error.message}`);
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--canary.490.72cc5dc.0",
4
+ "version": "2.0.0--canary.490.56e2519.0",
5
5
  "bin": {
6
6
  "frigg": "./frigg-cli/index.js"
7
7
  },
@@ -16,9 +16,9 @@
16
16
  "@babel/eslint-parser": "^7.18.9",
17
17
  "@babel/parser": "^7.25.3",
18
18
  "@babel/traverse": "^7.25.3",
19
- "@friggframework/core": "2.0.0--canary.490.72cc5dc.0",
20
- "@friggframework/schemas": "2.0.0--canary.490.72cc5dc.0",
21
- "@friggframework/test": "2.0.0--canary.490.72cc5dc.0",
19
+ "@friggframework/core": "2.0.0--canary.490.56e2519.0",
20
+ "@friggframework/schemas": "2.0.0--canary.490.56e2519.0",
21
+ "@friggframework/test": "2.0.0--canary.490.56e2519.0",
22
22
  "@hapi/boom": "^10.0.1",
23
23
  "@inquirer/prompts": "^5.3.8",
24
24
  "axios": "^1.7.2",
@@ -46,8 +46,8 @@
46
46
  "validate-npm-package-name": "^5.0.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@friggframework/eslint-config": "2.0.0--canary.490.72cc5dc.0",
50
- "@friggframework/prettier-config": "2.0.0--canary.490.72cc5dc.0",
49
+ "@friggframework/eslint-config": "2.0.0--canary.490.56e2519.0",
50
+ "@friggframework/prettier-config": "2.0.0--canary.490.56e2519.0",
51
51
  "aws-sdk-client-mock": "^4.1.0",
52
52
  "aws-sdk-client-mock-jest": "^4.1.0",
53
53
  "jest": "^30.1.3",
@@ -79,5 +79,5 @@
79
79
  "publishConfig": {
80
80
  "access": "public"
81
81
  },
82
- "gitHead": "72cc5dc761ed4396235fcfbe016c090833e65f9d"
82
+ "gitHead": "56e2519bb620b497d18bb354b8905e8a6c343a58"
83
83
  }