Skip to content

Instantly share code, notes, and snippets.

@filipeandre
Created November 25, 2024 18:52
Show Gist options
  • Save filipeandre/4a75b903ba7f3652592eb9c62aa13c10 to your computer and use it in GitHub Desktop.
Save filipeandre/4a75b903ba7f3652592eb9c62aa13c10 to your computer and use it in GitHub Desktop.
AWSTemplateFormatVersion: '2010-09-09'
Description: AWS EU West 1 VPN gateway with connections to Azure.
Parameters:
VpcId:
Type: AWS::EC2::VPC::Id
Description: ID of the existing VPC.
SubnetId:
Type: AWS::EC2::Subnet::Id
Description: ID of the existing Subnet.
AzurePrimaryGatewayIp:
Type: String
Description: Public IP address of the primary Azure gateway.
AzureSecondaryGatewayIp:
Type: String
Description: Public IP address of the secondary Azure gateway.
BgpAsn:
Type: Number
Default: 65515
Description: BGP ASN for the customer gateways.
Tunnel1PrimaryCidr:
Type: String
Default: 169.254.21.0/30
Description: Inside CIDR for tunnel 1 of the primary VPN connection.
Tunnel2PrimaryCidr:
Type: String
Default: 169.254.21.4/30
Description: Inside CIDR for tunnel 2 of the primary VPN connection.
Tunnel1SecondaryCidr:
Type: String
Default: 169.254.22.0/30
Description: Inside CIDR for tunnel 1 of the secondary VPN connection.
Tunnel2SecondaryCidr:
Type: String
Default: 169.254.22.4/30
Description: Inside CIDR for tunnel 2 of the secondary VPN connection.
Resources:
VPNGateway:
Type: AWS::EC2::VPNGateway
Properties:
Type: ipsec.1
Tags:
- Key: Name
Value: aws-gateway-001
VPNGatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref VpcId
VpnGatewayId: !Ref VPNGateway
VPNGatewayRoutePropagation:
Type: AWS::EC2::VPNGatewayRoutePropagation
Properties:
RouteTableIds:
- !Ref RouteTable
VpnGatewayId: !Ref VPNGateway
CustomerGatewayPrimary:
Type: AWS::EC2::CustomerGateway
Properties:
BgpAsn: !Ref BgpAsn
IpAddress: !Ref AzurePrimaryGatewayIp
Type: ipsec.1
Tags:
- Key: Name
Value: azure-gateway-001-primary
CustomerGatewaySecondary:
Type: AWS::EC2::CustomerGateway
Properties:
BgpAsn: !Ref BgpAsn
IpAddress: !Ref AzureSecondaryGatewayIp
Type: ipsec.1
Tags:
- Key: Name
Value: azure-gateway-001-secondary
VPNConnectionPrimary:
Type: AWS::EC2::VPNConnection
Properties:
VpnGatewayId: !Ref VPNGateway
CustomerGatewayId: !Ref CustomerGatewayPrimary
Type: ipsec.1
VpnTunnelOptionsSpecifications:
- TunnelInsideCidr: !Ref Tunnel1PrimaryCidr
- TunnelInsideCidr: !Ref Tunnel2PrimaryCidr
Tags:
- Key: Name
Value: azure-vpn-001-primary
VPNConnectionSecondary:
Type: AWS::EC2::VPNConnection
Properties:
VpnGatewayId: !Ref VPNGateway
CustomerGatewayId: !Ref CustomerGatewaySecondary
Type: ipsec.1
VpnTunnelOptionsSpecifications:
- TunnelInsideCidr: !Ref Tunnel1SecondaryCidr
- TunnelInsideCidr: !Ref Tunnel2SecondaryCidr
Tags:
- Key: Name
Value: azure-vpn-001-secondary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment