我正在使用Terraform在AWS上启动我的基础架构并将状态保存在.tfstate文件中 . 在我的应用程序中,我必须VPN到其他网络,其他网络的管理员已经在IPSec ESP连接上定义了我必须遵守的VPN连接的参数 .
使用Terraform我尽可能地使用远程网络的参数创建VPN网关和客户网关 . 然后我创建一个VPN连接和适当的路由 . 这是我在Terraform中的VPN代码:
resource "aws_vpn_gateway" "vpn_gw" {
vpc_id = "${aws_vpc.default.id}"
tags {
Name = "default"
Terraform = true
}
}
resource "aws_customer_gateway" "customer_gw" {
bgp_asn = 65000
ip_address = "172.0.0.1"
type = "ipsec.1"
}
resource "aws_vpn_connection" "default" {
vpn_gateway_id = "${aws_vpn_gateway.vpn_gw.id}"
customer_gateway_id = "${aws_customer_gateway.customer_gw.id}"
type = "ipsec.1"
static_routes_only = true
}
resource "aws_vpn_connection_route" "office" {
destination_cidr_block = "192.168.10.0/24"
vpn_connection_id = "${aws_vpn_connection.default.id}"
}
我必须能够在我的VPN隧道上为连接的阶段1和阶段2设置以下参数:
阶段1
-
Authentication Method 例如预共享秘密
-
Encryption Scheme 例如IKE
-
Diffie-Hellman Group 例如第2组
-
Encryption Algorithm 例如AES-256
-
Hashing Algorithm 例如SHA-1
-
Main or Aggressive Mode 例如主要模式
-
Lifetime (for renegotiation) 例如86400
阶段2
-
Encapsulation (ESP or AH) 例如ESP
-
Encryption Algorithm 例如AES-256
-
Authentication Algorithm 例如SHA-1
-
Perfect Forward Secrecy 例如NO-PFS
-
Lifetime (for renegotiation) 例如3600
VPN Customer Gateway上的文档显示您无法自己设置这么多参数:https://www.terraform.io/docs/providers/aws/r/customer_gateway.html Boto API也不允许设置任何其他参数 .
有没有办法设置这些参数(以编程方式)?
1 回答
不幸的是,你的问题的答案是否定的 . 这不是Terraform问题,因此,这是AWS提供的服务的限制 . 您没有使用AWS的基本解决方案获得该级别的配置 .
要实现您的目标,您需要启动EC2实例
使用OpenSwan,VyOS等滚动您自己,例如https://aws.amazon.com/marketplace/pp/B00JK5UPF6(仅限AWS成本)
使用AWS市场中的VPN设备,例如https://aws.amazon.com/marketplace/pp/B00OCG4OAA(您需要向供应商支付许可费以及AWS成本)