-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathtgw-routes.njk
42 lines (41 loc) · 1.23 KB
/
tgw-routes.njk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
AWSTemplateFormatVersion: "2010-09-09"
Description: >-
Setup Transit Gateway routes to spoke VPCs
Parameters:
VpcSubnetIDs:
Description: VPC subnets to associate with Transit Gateway
Type: List<AWS::EC2::Subnet::Id>
VpcId:
Description: The VPC ID
Type: AWS::EC2::VPC::Id
VpcRouteTableId:
Description: The VPC route table ID
Type: String
TransitGatewayId:
Description: The Transit Gateway ID
Type: String
Resources:
TransitGatewayAttachment:
Type: AWS::EC2::TransitGatewayAttachment
Properties:
SubnetIds: !Ref VpcSubnetIDs
Tags:
- Key: Application
Value: NetworkServiceTransitGateway
TransitGatewayId: !Ref TransitGatewayId
VpcId: !Ref VpcId
{% for spoke, spoke_data in TgwSpokes %}
TgwSpokeRoute{{ spoke | replace('-','') }}:
Type: 'AWS::EC2::Route'
DependsOn: TransitGatewayAttachment
Properties:
RouteTableId: !Ref VpcRouteTableId
TransitGatewayId: !Ref TransitGatewayId
DestinationCidrBlock: {{ spoke_data.CIDR }}
{% endfor %}
Outputs:
TransitGatewayAttachmentId:
Description: "Transit Gateway Attachment ID"
Value: !Ref TransitGatewayAttachment
Export:
Name: !Sub '${AWS::StackName}-TransitGatewayAttachmentId'