diff --git a/__tests__/fixtures/vpc_multiple_az_multiple_natgw_no_db.json b/__tests__/fixtures/vpc_multiple_az_multiple_natgw_no_db.json index 61377a9a..11e44133 100644 --- a/__tests__/fixtures/vpc_multiple_az_multiple_natgw_no_db.json +++ b/__tests__/fixtures/vpc_multiple_az_multiple_natgw_no_db.json @@ -205,6 +205,7 @@ }, "PublicRoute1": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { @@ -355,6 +356,7 @@ }, "PublicRoute2": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { @@ -505,6 +507,7 @@ }, "PublicRoute3": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { diff --git a/__tests__/fixtures/vpc_multiple_az_natgw_db.json b/__tests__/fixtures/vpc_multiple_az_natgw_db.json index de72699d..dafc8314 100644 --- a/__tests__/fixtures/vpc_multiple_az_natgw_db.json +++ b/__tests__/fixtures/vpc_multiple_az_natgw_db.json @@ -205,6 +205,7 @@ }, "PublicRoute1": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { @@ -418,6 +419,7 @@ }, "PublicRoute2": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { diff --git a/__tests__/fixtures/vpc_multiple_az_natgw_no_db.json b/__tests__/fixtures/vpc_multiple_az_natgw_no_db.json index 80637d1d..0440501d 100644 --- a/__tests__/fixtures/vpc_multiple_az_natgw_no_db.json +++ b/__tests__/fixtures/vpc_multiple_az_natgw_no_db.json @@ -205,6 +205,7 @@ }, "PublicRoute1": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { @@ -355,6 +356,7 @@ }, "PublicRoute2": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { diff --git a/__tests__/fixtures/vpc_multiple_az_no_natgw_db.json b/__tests__/fixtures/vpc_multiple_az_no_natgw_db.json index 0bbd62f4..efa3098c 100644 --- a/__tests__/fixtures/vpc_multiple_az_no_natgw_db.json +++ b/__tests__/fixtures/vpc_multiple_az_no_natgw_db.json @@ -127,6 +127,7 @@ }, "PublicRoute1": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { @@ -328,6 +329,7 @@ }, "PublicRoute2": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { diff --git a/__tests__/fixtures/vpc_multiple_az_no_natgw_no_db.json b/__tests__/fixtures/vpc_multiple_az_no_natgw_no_db.json index a25dc8b0..1248971e 100644 --- a/__tests__/fixtures/vpc_multiple_az_no_natgw_no_db.json +++ b/__tests__/fixtures/vpc_multiple_az_no_natgw_no_db.json @@ -127,6 +127,7 @@ }, "PublicRoute1": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { @@ -265,6 +266,7 @@ }, "PublicRoute2": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { diff --git a/__tests__/fixtures/vpc_multiple_az_single_natgw_no_db.json b/__tests__/fixtures/vpc_multiple_az_single_natgw_no_db.json index 9ed7f49c..ddfc3d08 100644 --- a/__tests__/fixtures/vpc_multiple_az_single_natgw_no_db.json +++ b/__tests__/fixtures/vpc_multiple_az_single_natgw_no_db.json @@ -172,6 +172,7 @@ }, "PublicRoute1": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { @@ -322,6 +323,7 @@ }, "PublicRoute2": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { diff --git a/__tests__/fixtures/vpc_single_az_natgw_db.json b/__tests__/fixtures/vpc_single_az_natgw_db.json index 66e89112..44e2e5c9 100644 --- a/__tests__/fixtures/vpc_single_az_natgw_db.json +++ b/__tests__/fixtures/vpc_single_az_natgw_db.json @@ -172,6 +172,7 @@ }, "PublicRoute1": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { diff --git a/__tests__/fixtures/vpc_single_az_natgw_no_db.json b/__tests__/fixtures/vpc_single_az_natgw_no_db.json index f397e8fc..910b956c 100644 --- a/__tests__/fixtures/vpc_single_az_natgw_no_db.json +++ b/__tests__/fixtures/vpc_single_az_natgw_no_db.json @@ -172,6 +172,7 @@ }, "PublicRoute1": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { diff --git a/__tests__/fixtures/vpc_single_az_no_natgw_db.json b/__tests__/fixtures/vpc_single_az_no_natgw_db.json index 0e540542..37ff7e8a 100644 --- a/__tests__/fixtures/vpc_single_az_no_natgw_db.json +++ b/__tests__/fixtures/vpc_single_az_no_natgw_db.json @@ -127,6 +127,7 @@ }, "PublicRoute1": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { diff --git a/__tests__/fixtures/vpc_single_az_no_natgw_no_db.json b/__tests__/fixtures/vpc_single_az_no_natgw_no_db.json index f07e7568..af798dab 100644 --- a/__tests__/fixtures/vpc_single_az_no_natgw_no_db.json +++ b/__tests__/fixtures/vpc_single_az_no_natgw_no_db.json @@ -127,6 +127,7 @@ }, "PublicRoute1": { "Type": "AWS::EC2::Route", + "DependsOn": ["InternetGatewayAttachment"], "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "RouteTableId": { diff --git a/example/package.json b/example/package.json index 09fb9600..e136ab28 100644 --- a/example/package.json +++ b/example/package.json @@ -16,11 +16,11 @@ "test": "sls invoke -f rds" }, "devDependencies": { - "aws-sdk": "2.578.0", - "serverless": "1.58.0", + "aws-sdk": "2.610.0", + "serverless": "1.61.3", "serverless-vpc-plugin": "smoketurner/serverless-vpc-plugin#master", "serverless-webpack": "5.3.1", - "webpack": "4.41.2", + "webpack": "4.41.5", "webpack-node-externals": "1.7.2" } } diff --git a/package-lock.json b/package-lock.json index 93ae8ebb..dc9d86e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "serverless-vpc-plugin", - "version": "0.9.4", + "version": "0.9.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 421e476f..2bfac772 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "serverless-vpc-plugin", - "version": "0.9.4", + "version": "0.9.5", "engines": { "node": ">=8.0" }, diff --git a/src/vpc.js b/src/vpc.js index 670dac5a..9e253ce2 100644 --- a/src/vpc.js +++ b/src/vpc.js @@ -1,3 +1,5 @@ +const { PUBLIC_SUBNET } = require('./constants'); + /** * Build a VPC * @@ -201,6 +203,11 @@ function buildRoute( }, }; + // fixes "route table rtb-x and network gateway igw-x belong to different networks" + // see https://stackoverflow.com/questions/48865762 + if (name === PUBLIC_SUBNET) { + route.DependsOn = ['InternetGatewayAttachment']; + } if (NatGatewayId) { route.Properties.NatGatewayId = { Ref: NatGatewayId,