Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terraform AWS Transit Gateway and VPN Static Routes

Using Terraform, I have created the Transit Gateway, VPN definitions and associated them with the Transit Gateway. However, unable to to define static routes.

when trying to add the static routes, the error says it must be added via the Transit Gateway API. However, I cannot find that syntax.

resource "aws_vpn_connection_route" "vpn-p-usw2-xxxxxx-route-001" {
  destination_cidr_block = "10.10.0.0/16"
  vpn_connection_id      = "${aws_vpn_connection.vpn-p-usw2-xxxxxx.id}"
}


Error: Error creating VPN connection route: 
InvalidVpnConnection.InvalidType: Static routes for vpn-0f6d1ac578b957bf1 
must be added through the Transit Gateway API.
        status code: 400, request id: 
f4e1c61c-be16-4dc7-a608- d7a5d6ad57c7
like image 908
mr_citizenkane Avatar asked Nov 24 '25 21:11

mr_citizenkane


1 Answers

Per https://docs.aws.amazon.com/vpc/latest/tgw/tgw-vpn-attachments.html

"For static VPNs, add the static routes to the transit gateway route table."

You need to:

  • Create a Transit Gateway Route Table
  • Add static routes targeting your VPN connection

You won't see these prefixes in the VPN console. The TGW is the one that needs to know about those routes and will send the traffic there correctly.

This also means that if you are using more than one Transit Gateway Route Table, you will need to add the static routes to all of the tables associated with VPCs that you want to route to this VPN.

like image 128
digarok Avatar answered Nov 27 '25 11:11

digarok



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!