Skip to content

Instantly share code, notes, and snippets.

@kun432
Created October 26, 2021 17:44
Show Gist options
  • Save kun432/fc54fa8ae8f77c0259778209ee798eeb to your computer and use it in GitHub Desktop.
Save kun432/fc54fa8ae8f77c0259778209ee798eeb to your computer and use it in GitHub Desktop.
terraformでbgp site2site vpn
resource "aws_customer_gateway" "cgw-main" {
bgp_asn = 65000
ip_address = var.cgw1
type = "ipsec.1"
tags = {
Name = "cgw-main"
}
}
resource "aws_customer_gateway" "cgw-sub" {
bgp_asn = 65000
ip_address = var.cgw2
type = "ipsec.1"
tags = {
Name = "cgw-sub"
}
}
resource "aws_vpn_gateway" "vpngw" {
vpc_id = module.vpc.vpc_id
amazon_side_asn = 64512
tags = {
Name = "vpngw"
}
}
resource "aws_vpn_connection" "vpncon-main" {
vpn_gateway_id = aws_vpn_gateway.vpngw.id
customer_gateway_id = aws_customer_gateway.cgw-main.id
type = "ipsec.1"
}
resource "aws_vpn_connection" "vpncon-sub" {
vpn_gateway_id = aws_vpn_gateway.vpngw.id
customer_gateway_id = aws_customer_gateway.cgw-sub.id
type = "ipsec.1"
}
resource "aws_vpn_gateway_route_propagation" "private-c" {
vpn_gateway_id = aws_vpn_gateway.vpngw.id
route_table_id = module.vpc.private_route_table_ids[0]
}
resource "aws_vpn_gateway_route_propagation" "private-d" {
vpn_gateway_id = aws_vpn_gateway.vpngw.id
route_table_id = module.vpc.private_route_table_ids[1]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment