@friggframework/devtools 2.0.0--canary.398.90b58c8.0 → 2.0.0--canary.398.53eac55.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.
@@ -473,8 +473,8 @@ const composeServerlessDefinition = async (AppDefinition) => {
473
473
  if (discoveredResources.defaultVpcId) {
474
474
  console.log(` VPC: ${discoveredResources.defaultVpcId}`);
475
475
  }
476
- if (discoveredResources.privateSubnetIds) {
477
- console.log(` Subnets: ${discoveredResources.privateSubnetIds.join(', ')}`);
476
+ if (discoveredResources.privateSubnetId1 && discoveredResources.privateSubnetId2) {
477
+ console.log(` Subnets: ${discoveredResources.privateSubnetId1}, ${discoveredResources.privateSubnetId2}`);
478
478
  }
479
479
  if (discoveredResources.defaultSecurityGroupId) {
480
480
  console.log(` Security Group: ${discoveredResources.defaultSecurityGroupId}`);
@@ -508,8 +508,8 @@ const composeServerlessDefinition = async (AppDefinition) => {
508
508
  // Add discovered resources to environment if available
509
509
  ...(discoveredResources.defaultVpcId && { AWS_DISCOVERY_VPC_ID: discoveredResources.defaultVpcId }),
510
510
  ...(discoveredResources.defaultSecurityGroupId && { AWS_DISCOVERY_SECURITY_GROUP_ID: discoveredResources.defaultSecurityGroupId }),
511
- ...(discoveredResources.privateSubnetIds && discoveredResources.privateSubnetIds[0] && { AWS_DISCOVERY_SUBNET_ID_1: discoveredResources.privateSubnetIds[0] }),
512
- ...(discoveredResources.privateSubnetIds && discoveredResources.privateSubnetIds[1] && { AWS_DISCOVERY_SUBNET_ID_2: discoveredResources.privateSubnetIds[1] }),
511
+ ...(discoveredResources.privateSubnetId1 && { AWS_DISCOVERY_SUBNET_ID_1: discoveredResources.privateSubnetId1 }),
512
+ ...(discoveredResources.privateSubnetId2 && { AWS_DISCOVERY_SUBNET_ID_2: discoveredResources.privateSubnetId2 }),
513
513
  ...(discoveredResources.publicSubnetId && { AWS_DISCOVERY_PUBLIC_SUBNET_ID: discoveredResources.publicSubnetId }),
514
514
  ...(discoveredResources.defaultRouteTableId && { AWS_DISCOVERY_ROUTE_TABLE_ID: discoveredResources.defaultRouteTableId }),
515
515
  ...(discoveredResources.defaultKmsKeyId && { AWS_DISCOVERY_KMS_KEY_ID: discoveredResources.defaultKmsKeyId }),
@@ -777,52 +777,53 @@ const composeServerlessDefinition = async (AppDefinition) => {
777
777
  // VPC configuration using discovered or explicitly provided resources
778
778
  const vpcConfig = {
779
779
  securityGroupIds: AppDefinition.vpc.securityGroupIds ||
780
- (discoveredResources.defaultSecurityGroupId ? [discoveredResources.defaultSecurityGroupId] : ['${env:AWS_DISCOVERY_SECURITY_GROUP_ID}']),
780
+ (discoveredResources.defaultSecurityGroupId ? [discoveredResources.defaultSecurityGroupId] : []),
781
781
  subnetIds: AppDefinition.vpc.subnetIds ||
782
- (discoveredResources.privateSubnetIds && discoveredResources.privateSubnetIds.length >= 2 ?
783
- [discoveredResources.privateSubnetIds[0], discoveredResources.privateSubnetIds[1]] :
784
- ['${env:AWS_DISCOVERY_SUBNET_ID_1}', '${env:AWS_DISCOVERY_SUBNET_ID_2}'])
782
+ (discoveredResources.privateSubnetId1 && discoveredResources.privateSubnetId2 ?
783
+ [discoveredResources.privateSubnetId1, discoveredResources.privateSubnetId2] :
784
+ [])
785
785
  };
786
786
 
787
- // Set VPC config for Lambda functions
788
- definition.provider.vpc = vpcConfig;
789
-
790
- // Add NAT Gateway for Lambda internet access (required for external API calls)
791
- // Even with existing VPC, Lambdas need guaranteed internet access for integrations
792
- definition.resources.Resources.FriggNATGatewayEIP = {
793
- Type: 'AWS::EC2::EIP',
794
- Properties: {
795
- Domain: 'vpc',
796
- Tags: [
797
- { Key: 'Name', Value: '${self:service}-${self:provider.stage}-nat-eip' }
798
- ]
799
- }
800
- };
787
+ // Set VPC config for Lambda functions only if we have valid subnet IDs
788
+ if (vpcConfig.subnetIds.length >= 2 && vpcConfig.securityGroupIds.length > 0) {
789
+ definition.provider.vpc = vpcConfig;
790
+
791
+ // Always create NAT Gateway for Lambda internet access
792
+ // Default VPCs don't have NAT gateways, so we need to create them
793
+ definition.resources.Resources.FriggNATGatewayEIP = {
794
+ Type: 'AWS::EC2::EIP',
795
+ Properties: {
796
+ Domain: 'vpc',
797
+ Tags: [
798
+ { Key: 'Name', Value: '${self:service}-${self:provider.stage}-nat-eip' }
799
+ ]
800
+ }
801
+ };
801
802
 
802
- definition.resources.Resources.FriggNATGateway = {
803
- Type: 'AWS::EC2::NatGateway',
804
- Properties: {
805
- AllocationId: { 'Fn::GetAtt': ['FriggNATGatewayEIP', 'AllocationId'] },
806
- SubnetId: discoveredResources.publicSubnetId || '${env:AWS_DISCOVERY_PUBLIC_SUBNET_ID}', // Discovery finds public subnet
807
- Tags: [
808
- { Key: 'Name', Value: '${self:service}-${self:provider.stage}-nat-gateway' }
809
- ]
810
- }
811
- };
803
+ definition.resources.Resources.FriggNATGateway = {
804
+ Type: 'AWS::EC2::NatGateway',
805
+ Properties: {
806
+ AllocationId: { 'Fn::GetAtt': ['FriggNATGatewayEIP', 'AllocationId'] },
807
+ SubnetId: discoveredResources.publicSubnetId || discoveredResources.privateSubnetId1, // Use first discovered subnet if no public subnet found
808
+ Tags: [
809
+ { Key: 'Name', Value: '${self:service}-${self:provider.stage}-nat-gateway' }
810
+ ]
811
+ }
812
+ };
812
813
 
813
- // Create route table for Lambda subnets to use NAT Gateway
814
- definition.resources.Resources.FriggLambdaRouteTable = {
815
- Type: 'AWS::EC2::RouteTable',
816
- Properties: {
817
- VpcId: discoveredResources.defaultVpcId || '${env:AWS_DISCOVERY_VPC_ID}',
818
- Tags: [
819
- { Key: 'Name', Value: '${self:service}-${self:provider.stage}-lambda-rt' }
820
- ]
821
- }
822
- };
814
+ // Create route table for Lambda subnets to use NAT Gateway
815
+ definition.resources.Resources.FriggLambdaRouteTable = {
816
+ Type: 'AWS::EC2::RouteTable',
817
+ Properties: {
818
+ VpcId: discoveredResources.defaultVpcId || { Ref: 'FriggVPC' },
819
+ Tags: [
820
+ { Key: 'Name', Value: '${self:service}-${self:provider.stage}-lambda-rt' }
821
+ ]
822
+ }
823
+ };
823
824
 
824
- definition.resources.Resources.FriggNATRoute = {
825
- Type: 'AWS::EC2::Route',
825
+ definition.resources.Resources.FriggNATRoute = {
826
+ Type: 'AWS::EC2::Route',
826
827
  Properties: {
827
828
  RouteTableId: { Ref: 'FriggLambdaRouteTable' },
828
829
  DestinationCidrBlock: '0.0.0.0/0',
@@ -830,44 +831,45 @@ const composeServerlessDefinition = async (AppDefinition) => {
830
831
  }
831
832
  };
832
833
 
833
- // Associate Lambda subnets with NAT Gateway route table
834
- definition.resources.Resources.FriggSubnet1RouteAssociation = {
835
- Type: 'AWS::EC2::SubnetRouteTableAssociation',
834
+ // Associate Lambda subnets with NAT Gateway route table
835
+ definition.resources.Resources.FriggSubnet1RouteAssociation = {
836
+ Type: 'AWS::EC2::SubnetRouteTableAssociation',
836
837
  Properties: {
837
- SubnetId: discoveredResources.privateSubnetIds?.[0] || '${env:AWS_DISCOVERY_SUBNET_ID_1}',
838
+ SubnetId: vpcConfig.subnetIds[0],
838
839
  RouteTableId: { Ref: 'FriggLambdaRouteTable' }
839
840
  }
840
841
  };
841
842
 
842
- definition.resources.Resources.FriggSubnet2RouteAssociation = {
843
- Type: 'AWS::EC2::SubnetRouteTableAssociation',
843
+ definition.resources.Resources.FriggSubnet2RouteAssociation = {
844
+ Type: 'AWS::EC2::SubnetRouteTableAssociation',
844
845
  Properties: {
845
- SubnetId: discoveredResources.privateSubnetIds?.[1] || '${env:AWS_DISCOVERY_SUBNET_ID_2}',
846
+ SubnetId: vpcConfig.subnetIds[1],
846
847
  RouteTableId: { Ref: 'FriggLambdaRouteTable' }
847
848
  }
848
849
  };
849
850
 
850
- // Add VPC endpoints for AWS service optimization (optional but recommended)
851
- if (AppDefinition.vpc.enableVPCEndpoints !== false) {
852
- definition.resources.Resources.VPCEndpointS3 = {
851
+ // Add VPC endpoints for AWS service optimization (optional but recommended)
852
+ if (AppDefinition.vpc.enableVPCEndpoints !== false) {
853
+ definition.resources.Resources.VPCEndpointS3 = {
853
854
  Type: 'AWS::EC2::VPCEndpoint',
854
855
  Properties: {
855
- VpcId: discoveredResources.defaultVpcId || '${env:AWS_DISCOVERY_VPC_ID}',
856
+ VpcId: discoveredResources.defaultVpcId,
856
857
  ServiceName: 'com.amazonaws.${self:provider.region}.s3',
857
858
  VpcEndpointType: 'Gateway',
858
859
  RouteTableIds: [{ Ref: 'FriggLambdaRouteTable' }]
859
860
  }
860
861
  };
861
862
 
862
- definition.resources.Resources.VPCEndpointDynamoDB = {
863
+ definition.resources.Resources.VPCEndpointDynamoDB = {
863
864
  Type: 'AWS::EC2::VPCEndpoint',
864
865
  Properties: {
865
- VpcId: discoveredResources.defaultVpcId || '${env:AWS_DISCOVERY_VPC_ID}',
866
+ VpcId: discoveredResources.defaultVpcId,
866
867
  ServiceName: 'com.amazonaws.${self:provider.region}.dynamodb',
867
868
  VpcEndpointType: 'Gateway',
868
869
  RouteTableIds: [{ Ref: 'FriggLambdaRouteTable' }]
869
870
  }
870
871
  };
872
+ }
871
873
  }
872
874
  }
873
875
  }
@@ -962,28 +964,8 @@ const composeServerlessDefinition = async (AppDefinition) => {
962
964
  definition.custom[queueReference] = queueName;
963
965
  }
964
966
 
965
- // Check if AWS discovery environment variables are missing and error
966
- const needsDiscovery = AppDefinition.vpc?.enable ||
967
- AppDefinition.encryption?.useDefaultKMSForFieldLevelEncryption ||
968
- AppDefinition.ssm?.enable;
969
-
970
- if (needsDiscovery && !process.env.AWS_DISCOVERY_VPC_ID) {
971
- console.error('❌ AWS discovery environment variables not found');
972
- console.error('');
973
- console.error('🚨 Your AppDefinition requires AWS discovery but variables are missing:');
974
- if (AppDefinition.vpc?.enable) console.error(' ❌ VPC support (vpc.enable: true)');
975
- if (AppDefinition.encryption?.useDefaultKMSForFieldLevelEncryption) console.error(' ❌ KMS encryption (encryption.useDefaultKMSForFieldLevelEncryption: true)');
976
- if (AppDefinition.ssm?.enable) console.error(' ❌ SSM parameters (ssm.enable: true)');
977
- console.error('');
978
- console.error('💡 Run AWS discovery before building:');
979
- console.error(' node node_modules/@friggframework/devtools/infrastructure/run-discovery.js');
980
- console.error('');
981
- console.error('🔧 Or use the build command which runs discovery automatically:');
982
- console.error(' npx frigg build');
983
-
984
- // Exit the process instead of throwing to avoid serverless circular reference issues
985
- process.exit(1);
986
- }
967
+ // Discovery has already run successfully at this point if needed
968
+ // The discoveredResources object contains all the necessary AWS resources
987
969
 
988
970
  // Add websocket function if enabled
989
971
  if (AppDefinition.websockets?.enable === true) {
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.398.90b58c8.0",
4
+ "version": "2.0.0--canary.398.53eac55.0",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-ec2": "^3.835.0",
7
7
  "@aws-sdk/client-kms": "^3.835.0",
@@ -9,7 +9,7 @@
9
9
  "@babel/eslint-parser": "^7.18.9",
10
10
  "@babel/parser": "^7.25.3",
11
11
  "@babel/traverse": "^7.25.3",
12
- "@friggframework/test": "2.0.0--canary.398.90b58c8.0",
12
+ "@friggframework/test": "2.0.0--canary.398.53eac55.0",
13
13
  "@hapi/boom": "^10.0.1",
14
14
  "@inquirer/prompts": "^5.3.8",
15
15
  "axios": "^1.7.2",
@@ -31,8 +31,8 @@
31
31
  "serverless-http": "^2.7.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@friggframework/eslint-config": "2.0.0--canary.398.90b58c8.0",
35
- "@friggframework/prettier-config": "2.0.0--canary.398.90b58c8.0",
34
+ "@friggframework/eslint-config": "2.0.0--canary.398.53eac55.0",
35
+ "@friggframework/prettier-config": "2.0.0--canary.398.53eac55.0",
36
36
  "prettier": "^2.7.1",
37
37
  "serverless": "3.39.0",
38
38
  "serverless-dotenv-plugin": "^6.0.0",
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "90b58c8e19b569bca169038b097a8b7358ca3268"
67
+ "gitHead": "53eac553535657eaeb3110634f14870418fbbeda"
68
68
  }