Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
Add DependsOn on PublicRoute's to the InternetGatewayAttachment (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
jplock authored Jan 25, 2020
1 parent 90e7b92 commit da4f229
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 5 deletions.
3 changes: 3 additions & 0 deletions __tests__/fixtures/vpc_multiple_az_multiple_natgw_no_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
},
"PublicRoute1": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down Expand Up @@ -355,6 +356,7 @@
},
"PublicRoute2": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down Expand Up @@ -505,6 +507,7 @@
},
"PublicRoute3": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down
2 changes: 2 additions & 0 deletions __tests__/fixtures/vpc_multiple_az_natgw_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
},
"PublicRoute1": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down Expand Up @@ -418,6 +419,7 @@
},
"PublicRoute2": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down
2 changes: 2 additions & 0 deletions __tests__/fixtures/vpc_multiple_az_natgw_no_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
},
"PublicRoute1": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down Expand Up @@ -355,6 +356,7 @@
},
"PublicRoute2": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down
2 changes: 2 additions & 0 deletions __tests__/fixtures/vpc_multiple_az_no_natgw_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
},
"PublicRoute1": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down Expand Up @@ -328,6 +329,7 @@
},
"PublicRoute2": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down
2 changes: 2 additions & 0 deletions __tests__/fixtures/vpc_multiple_az_no_natgw_no_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
},
"PublicRoute1": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down Expand Up @@ -265,6 +266,7 @@
},
"PublicRoute2": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down
2 changes: 2 additions & 0 deletions __tests__/fixtures/vpc_multiple_az_single_natgw_no_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
},
"PublicRoute1": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down Expand Up @@ -322,6 +323,7 @@
},
"PublicRoute2": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down
1 change: 1 addition & 0 deletions __tests__/fixtures/vpc_single_az_natgw_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
},
"PublicRoute1": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down
1 change: 1 addition & 0 deletions __tests__/fixtures/vpc_single_az_natgw_no_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
},
"PublicRoute1": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down
1 change: 1 addition & 0 deletions __tests__/fixtures/vpc_single_az_no_natgw_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
},
"PublicRoute1": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down
1 change: 1 addition & 0 deletions __tests__/fixtures/vpc_single_az_no_natgw_no_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
},
"PublicRoute1": {
"Type": "AWS::EC2::Route",
"DependsOn": ["InternetGatewayAttachment"],
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"RouteTableId": {
Expand Down
6 changes: 3 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-vpc-plugin",
"version": "0.9.4",
"version": "0.9.5",
"engines": {
"node": ">=8.0"
},
Expand Down
7 changes: 7 additions & 0 deletions src/vpc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { PUBLIC_SUBNET } = require('./constants');

/**
* Build a VPC
*
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit da4f229

Please sign in to comment.