Skip to content

Instantly share code, notes, and snippets.

@simplyadrian
Created March 5, 2016 01:38
Show Gist options
  • Save simplyadrian/070956a6298d1d78ea29 to your computer and use it in GitHub Desktop.
Save simplyadrian/070956a6298d1d78ea29 to your computer and use it in GitHub Desktop.
jinja2 sucky fucky
{% for cgwid, ip in customer_gateway_ip.iteritems() -%}
"{{ cgwid }}CustomerGateway" : {
"Properties" : {
"Type" : "ipsec.1",
"BgpAsn" : "65000",
"IpAddress" : "{{ ip }}",
"Tags" : [
{ "Key": "mGage:unit", "Value": "techops" },
{ "Key": "mGage:product", "Value": "network" },
{ "Key": "mGage:subproduct", "Value": "vpc-infrastructure" },
{ "Key": "mGage:env", "Value": { "Ref": "Environment" } },
{ "Key": "Name", "Value": { "Ref": "AWS::StackName" } }
]
},
"Type" : "AWS::EC2::CustomerGateway"
},
"VpnGateway" : {
"Properties" : {
"Type" : "ipsec.1",
"Tags" : [
{ "Key": "mGage:unit", "Value": "techops" },
{ "Key": "mGage:product", "Value": "network" },
{ "Key": "mGage:subproduct", "Value": "vpc-infrastructure" },
{ "Key": "mGage:env", "Value": { "Ref": "Environment" } },
{ "Key": "Name", "Value": { "Ref": "AWS::StackName" } }
]
},
"Type" : "AWS::EC2::VPNGateway"
},
"{{ cgwid }}VpnConnection": {
"Properties": {
"Type" : "ipsec.1",
"StaticRoutesOnly" : "true",
"CustomerGatewayId" : "{{ ip }}",
"VpnGatewayId" : {"Ref" : "VpnGateway"},
"Tags" : [
{ "Key": "mGage:unit", "Value": "techops" },
{ "Key": "mGage:product", "Value": "network" },
{ "Key": "mGage:subproduct", "Value": "vpc-infrastructure" },
{ "Key": "mGage:env", "Value": { "Ref": "Environment" } },
{ "Key": "Name", "Value": { "Ref": "AWS::StackName" } }
]
},
"DependsOn": "VpnGateway",
"Type" : "AWS::EC2::VPNConnection"
},
{% for routeid, cidr in static_routes.iteritems() -%}
"ConnectionRoute{{ routeid }}" : {
"Properties" : {
"DestinationCidrBlock" : "{{ cidr }}",
"VpnConnectionId" : { "Ref" : "{{ cgwid }}VpnConnection" }
},
"DependsOn": "VpnConnection",
"Type" : "AWS::EC2::VPNConnectionRoute"
},
{% endfor %}{# routeid_cidr -#}
{% endfor %}{# cgwid_ip -#}
customer_gateway_ip:
BosClt: 64.14.95.6
AtlProd: 208.71.240.10
AtlQa: 208.71.244.100
UkColt: 213.86.42.254
UkBis: 91.216.137.230
Sf: 216.74.44.254
LaCC: 38.122.246.66
static_routes:
BosClt:
A: 172.17.1.0/24
B: 192.168.10.0/24
C: 192.168.14.0/24
D: 192.168.66.0/24
E: 10.127.33.0/24
F: 10.1.1.0/24
G: 172.19.1.0/24
H: 192.168.3.0/24
AtlProd:
A: 192.168.16.0/24
B: 192.168.18.0/24
C: 192.168.20.0/24
D: 192.168.21.0/24
E: 192.168.22.0/24
F: 192.168.23.0/24
G: 192.168.24.0/24
H: 192.168.25.0/24
I: 192.168.26.0/24
J: 192.168.27.0/24
K: 192.168.28.0/24
L: 192.168.40.0/24
M: 192.168.41.0/24
N: 192.168.200.0/24
O: 10.130.80.0/24
P: 10.130.81.0/24
Q: 10.130.82.0/24
R: 10.130.83.0/24
S: 10.128.80.0/24
T: 10.128.81.0/24
U: 10.128.82.0/24
AtlQa:
A: 192.168.104.0/24
B: 192.168.100.0/24
C: 192.168.101.0/24
D: 192.168.11.0/24
E: 10.20.32.0/24
F: 10.20.33.0/24
G: 10.20.34.0/24
H: 10.20.35.0/24
I: 10.20.43.0/24
J: 192.168.105.0/24
K: 192.168.106.0/24
UkColt:
A: 10.50.1.0/24
B: 10.60.0.0/24
C: 10.60.1.0/24
D: 10.60.2.0/24
E: 10.60.3.0/24
F: 10.10.91.0/24
G: 10.128.224.0/24
H: 10.128.230.0/24
I: 10.128.231.0/24
J: 10.130.224.0/24
K: 10.130.225.0/24
L: 10.130.226.0/24
M: 10.130.227.0/24
N: 10.130.228.0/24
O: 10.130.229.0/24
P: 10.130.230.0/24
Q: 10.130.231.0/24
UkBis:
A: 192.168.110.0/24
B: 192.168.120.0/24
C: 10.128.191.0/24
D: 10.130.191.0/24
E: 192.168.1.0/24
Sf:
A: 10.20.0.0/24
B: 10.20.1.0/24
C: 172.31.240.144/28
D: 10.20.2.0/28
E: 10.20.2.64/26
F: 10.20.2.128/25
G: 10.20.4.0/23
H: 10.128.64.0/24
I: 10.128.79.0/24
J: 10.130.64.0/24
K: 10.130.79.0/24
LaCC:
A: 10.60.31.0/24
B: 10.60.24.0/24
C: 10.60.25.0/24
D: 10.60.26.0/24
E: 10.60.27.0/24
F: 172.16.99.0/24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment