123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710 |
- AWSTemplateFormatVersion: 2010-09-09
- Description: The template creates the TGW resource to connect on-premises firewall with cloud (qs-1qp7e9toe)
- Parameters:
- PrivateSubnet1ARouteTable:
- Type: String
- Description: Public Subnet 1 Route Table ID
- PrivateSubnet2ARouteTable:
- Type: String
- Description: Public Subnet 2 Route Table ID
- PrivateSubnet3ARouteTable:
- Type: String
- Default: 'null'
- Description: Public Subnet 3 Route Table ID
- PrivateSubnet4ARouteTable:
- Type: String
- Default: 'null'
- Description: Public Subnet 4 Route Table ID
- OnPremFirewallPublicIP:
- Description: Specify the Public IP of the on-premises ASAv/router
- Type: String
- OnPremFirewallASN:
- Description: Specify the BGP ASN of the on-premisis ASAv/router
- Type: String
- PreSharedKeyForVPNAttachment:
- Description: Specify the PreSharedKey of vEdgeCloud1. Must be 15 characters in length and cannot start with zero (0).
- Type: String
- AmazonSideAsn:
- Description: A private Autonomous System Number (ASN) for the Amazon side of a BGP session. The range is 64512 to 65534 for 16-bit ASNs and 4200000000 to 4294967294 for 32-bit ASNs.
- Type: String
- VPNTunnelCIDRs:
- Description: Specify the Tunnel InsideCIDRs for the on-premises firewall. You can use the default pre-filled CIDRs as well.
- Type: CommaDelimitedList
- VPCID:
- Type: AWS::EC2::VPC::Id
- Description: Select VPC which for VPC Attachment
- TGWSubnet1CIDR:
- AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(1[6-9]|2[0-8]))$
- ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
- Description: CIDR block for TGW subnet 1 located in Availability Zone 1
- Type: String
- TGWSubnet2CIDR:
- AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(1[6-9]|2[0-8]))$
- ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
- Description: CIDR block for TGW subnet 2 located in Availability Zone 1
- Type: String
- TGWSubnet3CIDR:
- AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(1[6-9]|2[0-8]))$
- ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
- Description: CIDR block for TGW subnet 3 located in Availability Zone 1
- Type: String
- TGWSubnet4CIDR:
- AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(1[6-9]|2[0-8]))$
- ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
- Description: CIDR block for TGW subnet 4 located in Availability Zone 1
- Type: String
- VPNPoolCIDR1:
- Description: CIDR block for the VPN pool 1
- Type: String
- VPNPoolCIDR2:
- Description: CIDR block for the VPN pool 2
- Type: String
- VPNPoolCIDR3:
- Description: CIDR block for the VPN pool 3
- Type: String
- VPNPoolCIDR4:
- Description: CIDR block for the VPN pool 4
- Type: String
- OnPremCIDR:
- AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(1[6-9]|2[0-8]))$
- ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28
- Description: CIDR block for the On-prem network
- Type: String
- AvailabilityZones:
- Description: >-
- List of Availability Zones to use for the subnets in the VPC. Note: The
- logical order is preserved and only 2 AZs are used for this deployment.
- Type: 'List<AWS::EC2::AvailabilityZone::Name>'
- NumberOfAZs:
- Description: >-
- Number of Availability Zones to use in the VPC. This must match your
- selections in the list of Availability Zones parameter.
- Type: String
- NumberOfASAv:
- Description: >-
- Number of ASAv Instances to be initiated.
- Type: String
- NetworkInterfaceId1ASAv1:
- Type: String
- Default: 'null'
- Description: NetworkInterfaceId of ASAv1 for 1 ASAv deployment
- NetworkInterfaceId1ASAv2:
- Type: String
- Default: 'null'
- Description: NetworkInterfaceId of ASAv1 for 2 ASAv deployment
- NetworkInterfaceId2ASAv2:
- Type: String
- Default: 'null'
- Description: NetworkInterfaceId of ASAv2 for 2 ASAv deployment
- NetworkInterfaceId1ASAv3:
- Type: String
- Default: 'null'
- Description: NetworkInterfaceId of ASAv1 for 3 ASAv deployment
- NetworkInterfaceId2ASAv3:
- Type: String
- Default: 'null'
- Description: NetworkInterfaceId of ASAv2 for 3 ASAv deployment
- NetworkInterfaceId3ASAv3:
- Type: String
- Default: 'null'
- Description: NetworkInterfaceId of ASAv3 for 3 ASAv deployment
- NetworkInterfaceId1ASAv4:
- Type: String
- Default: 'null'
- Description: NetworkInterfaceId of ASAv1 for 4 ASAv deployment
- NetworkInterfaceId2ASAv4:
- Type: String
- Default: 'null'
- Description: NetworkInterfaceId of ASAv2 for 4 ASAv deployment
- NetworkInterfaceId3ASAv4:
- Type: String
- Default: 'null'
- Description: NetworkInterfaceId of ASAv3 for 4 ASAv deployment
- NetworkInterfaceId4ASAv4:
- Type: String
- Default: 'null'
- Description: NetworkInterfaceId of ASAv4 for 4 ASAv deployment
- QSS3BucketName:
- AllowedPattern: "^[0-9a-zA-Z]+([0-9a-zA-Z-]*[0-9a-zA-Z])*$"
- ConstraintDescription: >-
- Quick Start bucket name can include numbers, lowercase letters, uppercase
- letters, and hyphens (-). It cannot start or end with a hyphen (-).
- Description: >-
- S3 bucket name for the Quick Start assets. Quick Start bucket name can
- include numbers, lowercase letters, uppercase letters, and hyphens (-). It
- cannot start or end with a hyphen (-).
- Type: String
- QSS3KeyPrefix:
- AllowedPattern: "^[0-9a-zA-Z-/]*$"
- ConstraintDescription: >-
- Quick Start key prefix can include numbers, lowercase letters, uppercase
- letters, hyphens (-), and forward slash (/).
- Description: >-
- S3 key prefix for the Quick Start assets. Quick Start key prefix can
- include numbers, lowercase letters, uppercase letters, hyphens (-), and
- forward slash (/).
- Type: String
- QSS3BucketRegion:
- Description: >-
- The AWS Region where the Quick Start S3 bucket (QSS3BucketName) is hosted.
- When using your own bucket, you must specify this value.
- Type: String
- Conditions:
- UsingDefaultBucket: !Equals
- - !Ref QSS3BucketName
- - aws-quickstart
- 1AZCondition: !Equals
- - !Ref 'NumberOfAZs'
- - '1'
- 2AZCondition: !Equals
- - !Ref 'NumberOfAZs'
- - '2'
- 3AZCondition: !Equals
- - !Ref 'NumberOfAZs'
- - '3'
- 4AZCondition: !Equals
- - !Ref 'NumberOfAZs'
- - '4'
- #Subnet conditions to specifically handle TGW Subnet Resource constraints
- 1SubnetCondition: !Or
- - !Equals
- - !Ref 'NumberOfAZs'
- - '1'
- - !Condition 2SubnetCondition
- - !Condition 3SubnetCondition
- - !Condition 4SubnetCondition
- 2SubnetCondition: !Or
- - !Equals
- - !Ref 'NumberOfAZs'
- - '2'
- - !Condition 3SubnetCondition
- - !Condition 4SubnetCondition
- 3SubnetCondition: !Or
- - !Equals
- - !Ref 'NumberOfAZs'
- - '3'
- - !Condition 4SubnetCondition
- 4SubnetCondition: !Equals
- - !Ref 'NumberOfAZs'
- - '4'
- 1ASAvCondition: !Equals
- - !Ref 'NumberOfASAv'
- - '1'
- 2ASAvCondition: !Equals
- - !Ref 'NumberOfASAv'
- - '2'
- 3ASAvCondition: !Equals
- - !Ref 'NumberOfASAv'
- - '3'
- 4ASAvCondition: !Equals
- - !Ref 'NumberOfASAv'
- - '4'
- Resources:
- #------------------ TGW Subnets and Routes -------------------------------------------
- TGWSubnet1:
- Type: AWS::EC2::Subnet
- Properties:
- VpcId: !Ref 'VPCID'
- CidrBlock: !Ref 'TGWSubnet1CIDR'
- AvailabilityZone: !Select
- - '0'
- - !Ref 'AvailabilityZones'
- Tags:
- - Key: Name
- Value: TGW subnet 1
- TGWSubnet2:
- Condition: 2SubnetCondition
- Type: AWS::EC2::Subnet
- Properties:
- VpcId: !Ref 'VPCID'
- CidrBlock: !Ref 'TGWSubnet2CIDR'
- AvailabilityZone: !Select
- - '1'
- - !Ref 'AvailabilityZones'
- Tags:
- - Key: Name
- Value: TGW subnet 2
- TGWSubnet3:
- Condition: 3SubnetCondition
- Type: AWS::EC2::Subnet
- Properties:
- VpcId: !Ref 'VPCID'
- CidrBlock: !Ref 'TGWSubnet3CIDR'
- AvailabilityZone: !Select
- - '2'
- - !Ref 'AvailabilityZones'
- Tags:
- - Key: Name
- Value: TGW subnet 3
- TGWSubnet4:
- Condition: 4AZCondition
- Type: AWS::EC2::Subnet
- Properties:
- VpcId: !Ref 'VPCID'
- CidrBlock: !Ref 'TGWSubnet4CIDR'
- AvailabilityZone: !Select
- - '3'
- - !Ref 'AvailabilityZones'
- Tags:
- - Key: Name
- Value: TGW subnet 4
- TGWSubnetRouteTable:
- Type: AWS::EC2::RouteTable
- Properties:
- VpcId: !Ref 'VPCID'
- Tags:
- - Key: Name
- Value: TGW subnets route table
- TGWSubnet1Route:
- Condition: 1ASAvCondition
- Type: AWS::EC2::Route
- Properties:
- RouteTableId: !Ref 'TGWSubnetRouteTable'
- DestinationCidrBlock: !Ref VPNPoolCIDR1
- NetworkInterfaceId: !Ref NetworkInterfaceId1ASAv1
- TGWSubnet1Route2ASAv:
- Condition: 2ASAvCondition
- Type: AWS::EC2::Route
- Properties:
- RouteTableId: !Ref 'TGWSubnetRouteTable'
- DestinationCidrBlock: !Ref VPNPoolCIDR1
- NetworkInterfaceId: !Ref NetworkInterfaceId1ASAv2
- TGWSubnet1Route3ASAv:
- Condition: 3ASAvCondition
- Type: AWS::EC2::Route
- Properties:
- RouteTableId: !Ref 'TGWSubnetRouteTable'
- DestinationCidrBlock: !Ref VPNPoolCIDR1
- NetworkInterfaceId: !Ref NetworkInterfaceId1ASAv3
- TGWSubnet1Route4ASAv:
- Condition: 4ASAvCondition
- Type: AWS::EC2::Route
- Properties:
- RouteTableId: !Ref 'TGWSubnetRouteTable'
- DestinationCidrBlock: !Ref VPNPoolCIDR1
- NetworkInterfaceId: !Ref NetworkInterfaceId1ASAv4
- TGWSubnet1AZRouteTableAssociation:
- Type: AWS::EC2::SubnetRouteTableAssociation
- Properties:
- SubnetId: !Ref 'TGWSubnet1'
- RouteTableId: !Ref 'TGWSubnetRouteTable'
- TGWSubnet2Route:
- Condition: 2ASAvCondition
- Type: AWS::EC2::Route
- Properties:
- RouteTableId: !Ref 'TGWSubnetRouteTable'
- DestinationCidrBlock: !Ref VPNPoolCIDR2
- NetworkInterfaceId: !Ref NetworkInterfaceId2ASAv2
- TGWSubnet2Route3ASAv:
- Condition: 3ASAvCondition
- Type: AWS::EC2::Route
- Properties:
- RouteTableId: !Ref 'TGWSubnetRouteTable'
- DestinationCidrBlock: !Ref VPNPoolCIDR2
- NetworkInterfaceId: !Ref NetworkInterfaceId2ASAv3
- TGWSubnet2Route4ASAv:
- Condition: 4ASAvCondition
- Type: AWS::EC2::Route
- Properties:
- RouteTableId: !Ref 'TGWSubnetRouteTable'
- DestinationCidrBlock: !Ref VPNPoolCIDR2
- NetworkInterfaceId: !Ref NetworkInterfaceId2ASAv4
- TGWSubnet2AZRouteTableAssociation:
- Condition: 2SubnetCondition
- Type: AWS::EC2::SubnetRouteTableAssociation
- Properties:
- SubnetId: !Ref 'TGWSubnet2'
- RouteTableId: !Ref 'TGWSubnetRouteTable'
- TGWSubnet3Route:
- Condition: 3ASAvCondition
- Type: AWS::EC2::Route
- Properties:
- RouteTableId: !Ref 'TGWSubnetRouteTable'
- DestinationCidrBlock: !Ref VPNPoolCIDR3
- NetworkInterfaceId: !Ref NetworkInterfaceId3ASAv3
- TGWSubnet3Route4ASAv:
- Condition: 4ASAvCondition
- Type: AWS::EC2::Route
- Properties:
- RouteTableId: !Ref 'TGWSubnetRouteTable'
- DestinationCidrBlock: !Ref VPNPoolCIDR3
- NetworkInterfaceId: !Ref NetworkInterfaceId3ASAv4
- TGWSubnet3AZRouteTableAssociation:
- Condition: 3SubnetCondition
- Type: AWS::EC2::SubnetRouteTableAssociation
- Properties:
- SubnetId: !Ref 'TGWSubnet3'
- RouteTableId: !Ref 'TGWSubnetRouteTable'
- TGWSubnet4Route:
- Condition: 4ASAvCondition
- Type: AWS::EC2::Route
- Properties:
- RouteTableId: !Ref 'TGWSubnetRouteTable'
- DestinationCidrBlock: !Ref VPNPoolCIDR4
- NetworkInterfaceId: !Ref NetworkInterfaceId4ASAv4
- TGWSubnet4AZRouteTableAssociation:
- Condition: 4SubnetCondition
- Type: AWS::EC2::SubnetRouteTableAssociation
- Properties:
- SubnetId: !Ref 'TGWSubnet4'
- RouteTableId: !Ref 'TGWSubnetRouteTable'
- #------------------ Transit Gateway -------------------------------------------
- TransitGateway:
- Type: "AWS::EC2::TransitGateway"
- Properties:
- AmazonSideAsn: !Ref AmazonSideAsn
- AutoAcceptSharedAttachments: enable
- DefaultRouteTableAssociation: disable
- DefaultRouteTablePropagation: disable
- Description: A transit gateway connect onpremsised with AWS
- Tags:
- - Key: Name
- Value: !Sub ${AWS::StackName}-TGW
- #------------------ Copy lambda stack into local S3 bucket ------------------------------------------------
- CopyLambdaStack:
- Type: AWS::CloudFormation::Stack
- Properties:
- #TemplateURL: !Sub "https://${QSS3BucketName}.s3.amazonaws.com/${QSS3KeyPrefix}templates/copy-lambdas.yaml"
- TemplateURL: !Sub
- - >-
- https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}templates/copy-lambdas.yaml
- - S3Region: !If
- - UsingDefaultBucket
- - !Ref 'AWS::Region'
- - !Ref QSS3BucketRegion
- S3Bucket: !If
- - UsingDefaultBucket
- - !Sub '${QSS3BucketName}-${AWS::Region}'
- - !Ref QSS3BucketName
- Parameters:
- QSS3BucketName: !Ref QSS3BucketName
- QSS3KeyPrefix: !Ref QSS3KeyPrefix
- ##------------------ Custom Resource lambda to get the various TGW properties needed -------------------------------------------
- LambdaBasicExecutionRole:
- Type: AWS::IAM::Role
- Properties:
- AssumeRolePolicyDocument:
- Statement:
- - Effect: Allow
- Principal:
- Service: lambda.amazonaws.com
- Action: sts:AssumeRole
- Condition: {}
- Path: /
- Policies:
- - PolicyName: !Sub ${AWS::StackName}-tgwDescribe
- PolicyDocument:
- Version: 2012-10-17
- Statement:
- - Effect: Allow
- Action:
- - logs:CreateLogGroup
- - logs:CreateLogStream
- - logs:PutLogEvents
- Resource: !Sub arn:${AWS::Partition}:logs:*:*:*
- - Effect: Allow
- Action:
- - ec2:DescribeVpnConnections
- - ec2:DescribeTransitGatewayRouteTables
- - ec2:DescribeTransitGatewayAttachments
- Resource: "*"
- TransitGatewayProperties:
- Type: Custom::TransitGatewayProperty
- Properties:
- ServiceToken: !GetAtt 'TransitGatewayLambda.Arn'
- vpn_id: !Ref VPNAttachment
- stackName: !Ref "AWS::StackName"
- TransitGatewayLambda:
- Type: AWS::Lambda::Function
- Properties:
- Handler: getTgwProperties/lambda_function.lambda_handler
- Timeout: 60
- Role: !GetAtt 'LambdaBasicExecutionRole.Arn'
- Runtime: python3.6
- Code:
- S3Bucket: !GetAtt 'CopyLambdaStack.Outputs.LambdaZipsBucket'
- S3Key: !Sub "${QSS3KeyPrefix}functions/packages/lambda.zip"
- MemorySize: 3008
- #------------------ TGW Route Tables and Routes -------------------------------------------
- TransitGatewaySecurityRouteTable:
- Type: "AWS::EC2::TransitGatewayRouteTable"
- Properties:
- Tags:
- - Key: Name
- Value: !Sub ${AWS::StackName}-Securityrtb
- TransitGatewayId: !Ref TransitGateway
- TransitGatewayVPNRoute:
- Type: AWS::EC2::TransitGatewayRoute
- Properties:
- DestinationCidrBlock: !Ref OnPremCIDR
- TransitGatewayAttachmentId: !GetAtt TransitGatewayProperties.vpn1_tgw_attachment_id
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- TransitGatewayVPNPoolRoute1:
- Condition: 1ASAvCondition
- Type: AWS::EC2::TransitGatewayRoute
- Properties:
- DestinationCidrBlock: !Ref VPNPoolCIDR1
- TransitGatewayAttachmentId: !Ref VPCAttachment1AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- TransitGatewayVPNPoolRoute2a:
- Condition: 2ASAvCondition
- Type: AWS::EC2::TransitGatewayRoute
- Properties:
- DestinationCidrBlock: !Ref VPNPoolCIDR1
- TransitGatewayAttachmentId: !Ref VPCAttachment2AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- TransitGatewayVPNPoolRoute2b:
- Condition: 2ASAvCondition
- Type: AWS::EC2::TransitGatewayRoute
- Properties:
- DestinationCidrBlock: !Ref VPNPoolCIDR2
- TransitGatewayAttachmentId: !Ref VPCAttachment2AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- TransitGatewayVPNPoolRoute3a:
- Condition: 3ASAvCondition
- Type: AWS::EC2::TransitGatewayRoute
- Properties:
- DestinationCidrBlock: !Ref VPNPoolCIDR1
- TransitGatewayAttachmentId: !Ref VPCAttachment3AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- TransitGatewayVPNPoolRoute3b:
- Condition: 3ASAvCondition
- Type: AWS::EC2::TransitGatewayRoute
- Properties:
- DestinationCidrBlock: !Ref VPNPoolCIDR2
- TransitGatewayAttachmentId: !Ref VPCAttachment3AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- TransitGatewayVPNPoolRoute3c:
- Condition: 3ASAvCondition
- Type: AWS::EC2::TransitGatewayRoute
- Properties:
- DestinationCidrBlock: !Ref VPNPoolCIDR3
- TransitGatewayAttachmentId: !Ref VPCAttachment3AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- TransitGatewayVPNPoolRoute4a:
- Condition: 4ASAvCondition
- Type: AWS::EC2::TransitGatewayRoute
- Properties:
- DestinationCidrBlock: !Ref VPNPoolCIDR1
- TransitGatewayAttachmentId: !Ref VPCAttachment4AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- TransitGatewayVPNPoolRoute4b:
- Condition: 4ASAvCondition
- Type: AWS::EC2::TransitGatewayRoute
- Properties:
- DestinationCidrBlock: !Ref VPNPoolCIDR2
- TransitGatewayAttachmentId: !Ref VPCAttachment4AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- TransitGatewayVPNPoolRoute4c:
- Condition: 4ASAvCondition
- Type: AWS::EC2::TransitGatewayRoute
- Properties:
- DestinationCidrBlock: !Ref VPNPoolCIDR3
- TransitGatewayAttachmentId: !Ref VPCAttachment4AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- TransitGatewayVPNPoolRoute4d:
- Condition: 4ASAvCondition
- Type: AWS::EC2::TransitGatewayRoute
- Properties:
- DestinationCidrBlock: !Ref VPNPoolCIDR4
- TransitGatewayAttachmentId: !Ref VPCAttachment4AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- TransitGatewaySpokeRouteTable:
- Type: "AWS::EC2::TransitGatewayRouteTable"
- Properties:
- Tags:
- - Key: Name
- Value: !Sub ${AWS::StackName}-Spokertb
- TransitGatewayId: !Ref TransitGateway
- #------------------ TGW VPN attachment -------------------------------------------
- CustomerGateway:
- Type: AWS::EC2::CustomerGateway
- Properties:
- Type: ipsec.1
- BgpAsn: !Ref OnPremFirewallASN
- IpAddress: !Ref OnPremFirewallPublicIP
- Tags:
- - Key: Name
- Value: !Sub "${AWS::StackName}-On-Premgateway"
- VPNAttachment:
- Type: AWS::EC2::VPNConnection
- Properties:
- CustomerGatewayId: !Ref CustomerGateway
- TransitGatewayId: !Ref TransitGateway
- Type: ipsec.1
- VpnTunnelOptionsSpecifications:
- - PreSharedKey: !Ref PreSharedKeyForVPNAttachment
- TunnelInsideCidr: !Select [0, !Ref VPNTunnelCIDRs]
- - PreSharedKey: !Ref PreSharedKeyForVPNAttachment
- TunnelInsideCidr: !Select [1, !Ref VPNTunnelCIDRs]
- Tags:
- - Key: Name
- Value: !Sub "${AWS::StackName}-VPNAttachment"
- #------------------ TGW VPC attachments -------------------------------------------
- VPCAttachment1AZ:
- Condition: 1AZCondition
- Type: AWS::EC2::TransitGatewayAttachment
- Properties:
- SubnetIds:
- - !Ref TGWSubnet1
- Tags:
- - Key: Name
- Value: !Sub "${AWS::StackName}-VPCAttachment"
- TransitGatewayId: !Ref TransitGateway
- VpcId: !Ref VPCID
- VPCAttachment2AZ:
- Condition: 2AZCondition
- Type: AWS::EC2::TransitGatewayAttachment
- Properties:
- SubnetIds:
- - !Ref TGWSubnet1
- - !Ref TGWSubnet2
- Tags:
- - Key: Name
- Value: !Sub "${AWS::StackName}-VPCAttachment"
- TransitGatewayId: !Ref TransitGateway
- VpcId: !Ref VPCID
- VPCAttachment3AZ:
- Condition: 3AZCondition
- Type: AWS::EC2::TransitGatewayAttachment
- Properties:
- SubnetIds:
- - !Ref TGWSubnet1
- - !Ref TGWSubnet2
- - !Ref TGWSubnet3
- Tags:
- - Key: Name
- Value: !Sub "${AWS::StackName}-VPCAttachment"
- TransitGatewayId: !Ref TransitGateway
- VpcId: !Ref VPCID
- VPCAttachment4AZ:
- Condition: 4AZCondition
- Type: AWS::EC2::TransitGatewayAttachment
- Properties:
- SubnetIds:
- - !Ref TGWSubnet1
- - !Ref TGWSubnet2
- - !Ref TGWSubnet3
- - !Ref TGWSubnet4
- Tags:
- - Key: Name
- Value: !Sub "${AWS::StackName}-VPCAttachment"
- TransitGatewayId: !Ref TransitGateway
- VpcId: !Ref VPCID
- #------------------ TGW route table associations -------------------------------------------
- CustomerGatewayTransitGatewayAssociation:
- Type: "AWS::EC2::TransitGatewayRouteTableAssociation"
- Properties:
- TransitGatewayAttachmentId: !GetAtt TransitGatewayProperties.vpn1_tgw_attachment_id
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- #The VPC association works
- VPCTransitGatewayAssociation1AZ:
- Condition: 1AZCondition
- Type: "AWS::EC2::TransitGatewayRouteTableAssociation"
- Properties:
- TransitGatewayAttachmentId: !Ref VPCAttachment1AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- VPCTransitGatewayAssociation2AZ:
- Condition: 2AZCondition
- Type: "AWS::EC2::TransitGatewayRouteTableAssociation"
- Properties:
- TransitGatewayAttachmentId: !Ref VPCAttachment2AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- VPCTransitGatewayAssociation3AZ:
- Condition: 3AZCondition
- Type: "AWS::EC2::TransitGatewayRouteTableAssociation"
- Properties:
- TransitGatewayAttachmentId: !Ref VPCAttachment3AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- VPCTransitGatewayAssociation4AZ:
- Condition: 4AZCondition
- Type: "AWS::EC2::TransitGatewayRouteTableAssociation"
- Properties:
- TransitGatewayAttachmentId: !Ref VPCAttachment4AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- #------------------ TGW route table propagations -------------------------------------------
- EdgeRouteTablePropagation1AZ:
- Condition: 1AZCondition
- Type: "AWS::EC2::TransitGatewayRouteTablePropagation"
- Properties:
- TransitGatewayAttachmentId: !Ref VPCAttachment1AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- EdgeRouteTablePropagation2AZ:
- Condition: 2AZCondition
- Type: "AWS::EC2::TransitGatewayRouteTablePropagation"
- Properties:
- TransitGatewayAttachmentId: !Ref VPCAttachment2AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- EdgeRouteTablePropagation3AZ:
- Condition: 3AZCondition
- Type: "AWS::EC2::TransitGatewayRouteTablePropagation"
- Properties:
- TransitGatewayAttachmentId: !Ref VPCAttachment3AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- EdgeRouteTablePropagation4AZ:
- Condition: 4AZCondition
- Type: "AWS::EC2::TransitGatewayRouteTablePropagation"
- Properties:
- TransitGatewayAttachmentId: !Ref VPCAttachment4AZ
- TransitGatewayRouteTableId: !Ref TransitGatewaySecurityRouteTable
- RouteTableEntryPrivate1:
- Type: AWS::EC2::Route
- DependsOn: TransitGatewayVPNRoute
- Properties:
- DestinationCidrBlock: !Ref OnPremCIDR
- RouteTableId: !Ref PrivateSubnet1ARouteTable
- TransitGatewayId: !Ref TransitGateway
- RouteTableEntryPrivate2:
- Condition: 2SubnetCondition
- Type: AWS::EC2::Route
- DependsOn: TransitGatewayVPNRoute
- #DependsOn: VPCAttachment2AZ
- Properties:
- DestinationCidrBlock: !Ref OnPremCIDR
- RouteTableId: !Ref PrivateSubnet2ARouteTable
- TransitGatewayId: !Ref TransitGateway
- RouteTableEntryPrivate3:
- Condition: 3SubnetCondition
- DependsOn: TransitGatewayVPNRoute
- #DependsOn: VPCAttachment3AZ
- Type: AWS::EC2::Route
- Properties:
- DestinationCidrBlock: !Ref OnPremCIDR
- RouteTableId: !Ref PrivateSubnet3ARouteTable
- TransitGatewayId: !Ref TransitGateway
- RouteTableEntryPrivate4:
- Condition: 4SubnetCondition
- Type: AWS::EC2::Route
- DependsOn: TransitGatewayVPNRoute
- #DependsOn: VPCAttachment4AZ
- Properties:
- DestinationCidrBlock: !Ref OnPremCIDR
- RouteTableId: !Ref PrivateSubnet4ARouteTable
- TransitGatewayId: !Ref TransitGateway
- Outputs:
- TransitGateway:
- Value: !Ref TransitGateway
- Export:
- Name: !Sub ${AWS::StackName}-TransitGateway
- AmazonSideAsn:
- Description: "Amazon side ASN for the BGP session"
- Value: !Ref AmazonSideAsn
- VPNTunnelInsideCIDRs:
- Description: "VPN Tunnel CIDRs"
- Value: !Join
- - ','
- - !Ref VPNTunnelCIDRs
- Export:
- Name: !Sub ${AWS::StackName}-VPNTunnelInsideCIDRs
- VPNTunnelOutsideIPs:
- Description: "VPN Tunnel Outside IP"
- Value: !Join
- - ','
- - !GetAtt TransitGatewayProperties.vpn0OutsideIps
- Export:
- Name: !Sub ${AWS::StackName}-VPNTunnelOutsideIPs
- VPNPreSharedKey:
- Description: "VPN IPsec PreSharedKey"
- Value: !Ref PreSharedKeyForVPNAttachment
- Export:
- Name: !Sub ${AWS::StackName}-PreSharedKey
|