@friggframework/devtools 2.0.0--canary.461.d5b9ddf.0 → 2.0.0--canary.461.1b7f17f.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.
@@ -110,7 +110,23 @@ class VpcBuilder extends InfrastructureBuilder {
110
110
  Resource: '*',
111
111
  });
112
112
 
113
- const management = appDefinition.vpc.management || 'discover';
113
+ // Normalize shareAcrossStages into management mode
114
+ // This provides a simpler API for users while maintaining backwards compatibility
115
+ let management = appDefinition.vpc.management;
116
+ if (!management && appDefinition.vpc.shareAcrossStages !== undefined) {
117
+ // Explicit shareAcrossStages setting overrides default
118
+ management = appDefinition.vpc.shareAcrossStages ? 'discover' : 'create-new';
119
+ console.log(` VPC Sharing: ${appDefinition.vpc.shareAcrossStages ? 'shared' : 'isolated'} (translated to ${management})`);
120
+
121
+ // When creating isolated VPC, also create isolated NAT Gateway
122
+ if (!appDefinition.vpc.shareAcrossStages && !appDefinition.vpc.natGateway?.management) {
123
+ appDefinition.vpc.natGateway = appDefinition.vpc.natGateway || {};
124
+ appDefinition.vpc.natGateway.management = 'createAndManage';
125
+ console.log(` NAT Gateway: creating isolated NAT (shareAcrossStages=false)`);
126
+ }
127
+ } else {
128
+ management = management || 'discover'; // Default to sharing for backwards compatibility
129
+ }
114
130
  console.log(` VPC Management Mode: ${management}`);
115
131
 
116
132
  // Handle self-healing if enabled
@@ -809,6 +809,81 @@ describe('VpcBuilder', () => {
809
809
  });
810
810
  });
811
811
 
812
+ describe('VPC Sharing Control', () => {
813
+ it('should share VPC across stages when shareAcrossStages is true (default)', async () => {
814
+ const appDefinition = {
815
+ vpc: {
816
+ enable: true,
817
+ shareAcrossStages: true, // Explicit opt-in to sharing
818
+ },
819
+ };
820
+
821
+ const discoveredResources = {
822
+ defaultVpcId: 'vpc-shared',
823
+ natGatewayId: 'nat-shared',
824
+ };
825
+
826
+ const result = await vpcBuilder.build(appDefinition, discoveredResources);
827
+
828
+ // Should use discovered VPC (not create new one)
829
+ expect(result.vpcId).toBe('vpc-shared');
830
+ expect(result.resources.FriggVPC).toBeUndefined();
831
+
832
+ // Should create stage-specific subnets for isolation
833
+ expect(result.resources.FriggPrivateSubnet1).toBeDefined();
834
+ expect(result.resources.FriggPrivateSubnet2).toBeDefined();
835
+
836
+ // Should reuse discovered NAT Gateway
837
+ expect(result.resources.FriggNATGateway).toBeUndefined();
838
+ });
839
+
840
+ it('should create isolated VPC when shareAcrossStages is false', async () => {
841
+ const appDefinition = {
842
+ vpc: {
843
+ enable: true,
844
+ shareAcrossStages: false, // Explicit opt-out of sharing
845
+ },
846
+ };
847
+
848
+ const discoveredResources = {
849
+ defaultVpcId: 'vpc-shared',
850
+ natGatewayId: 'nat-shared',
851
+ };
852
+
853
+ const result = await vpcBuilder.build(appDefinition, discoveredResources);
854
+
855
+ // Should create new VPC (ignore discovered resources)
856
+ expect(result.vpcId).toEqual({ Ref: 'FriggVPC' });
857
+ expect(result.resources.FriggVPC).toBeDefined();
858
+
859
+ // Should create stage-specific subnets
860
+ expect(result.resources.FriggPrivateSubnet1).toBeDefined();
861
+ expect(result.resources.FriggPrivateSubnet2).toBeDefined();
862
+
863
+ // Should create new NAT Gateway
864
+ expect(result.resources.FriggNATGateway).toBeDefined();
865
+ });
866
+
867
+ it('should default to shared VPC when shareAcrossStages is not specified', async () => {
868
+ const appDefinition = {
869
+ vpc: {
870
+ enable: true,
871
+ // shareAcrossStages not specified - should default to true
872
+ },
873
+ };
874
+
875
+ const discoveredResources = {
876
+ defaultVpcId: 'vpc-discovered',
877
+ };
878
+
879
+ const result = await vpcBuilder.build(appDefinition, discoveredResources);
880
+
881
+ // Should use discovered VPC by default (backwards compatibility)
882
+ expect(result.vpcId).toBe('vpc-discovered');
883
+ expect(result.resources.FriggVPC).toBeUndefined();
884
+ });
885
+ });
886
+
812
887
  describe('Outputs', () => {
813
888
  it.skip('should generate VPC ID output', async () => {
814
889
  const appDefinition = {
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.461.d5b9ddf.0",
4
+ "version": "2.0.0--canary.461.1b7f17f.0",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-ec2": "^3.835.0",
7
7
  "@aws-sdk/client-kms": "^3.835.0",
@@ -11,8 +11,8 @@
11
11
  "@babel/eslint-parser": "^7.18.9",
12
12
  "@babel/parser": "^7.25.3",
13
13
  "@babel/traverse": "^7.25.3",
14
- "@friggframework/schemas": "2.0.0--canary.461.d5b9ddf.0",
15
- "@friggframework/test": "2.0.0--canary.461.d5b9ddf.0",
14
+ "@friggframework/schemas": "2.0.0--canary.461.1b7f17f.0",
15
+ "@friggframework/test": "2.0.0--canary.461.1b7f17f.0",
16
16
  "@hapi/boom": "^10.0.1",
17
17
  "@inquirer/prompts": "^5.3.8",
18
18
  "axios": "^1.7.2",
@@ -34,8 +34,8 @@
34
34
  "serverless-http": "^2.7.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@friggframework/eslint-config": "2.0.0--canary.461.d5b9ddf.0",
38
- "@friggframework/prettier-config": "2.0.0--canary.461.d5b9ddf.0",
37
+ "@friggframework/eslint-config": "2.0.0--canary.461.1b7f17f.0",
38
+ "@friggframework/prettier-config": "2.0.0--canary.461.1b7f17f.0",
39
39
  "aws-sdk-client-mock": "^4.1.0",
40
40
  "aws-sdk-client-mock-jest": "^4.1.0",
41
41
  "jest": "^30.1.3",
@@ -70,5 +70,5 @@
70
70
  "publishConfig": {
71
71
  "access": "public"
72
72
  },
73
- "gitHead": "d5b9ddfa8deb275e2275139ca229781776609fa4"
73
+ "gitHead": "1b7f17f4433c6c8b563bab075f0c91335a1a0ad7"
74
74
  }