{ description = "fgtvm-port1" subnet_id = aws_subnet.publicsubnetaz1.id } resource "aws_network_interface" "eth1" { description = "fgtvm-port2" subnet_id = aws_subnet.privatesubnetaz1.id source_dest_check = false } resource "aws_network_interface_sg_attachment" "publicattachment" { depends_on = [aws_network_interface.eth0] security_group_id = aws_security_group.public_allow.id network_interface_id = aws_network_interface.eth0.id } resource "aws_network_interface_sg_attachment" "internalattachment" { depends_on = [aws_network_interface.eth1] security_group_id = aws_security_group.allow_all.id network_interface_id = aws_network_interface.eth1.id } resource "aws_instance" "fgtvm" { ami = var.license_type == "byol" ? var.fgtvmbyolami[var.region] : var.fgtvmami[var.region] instance_type = var.size availability_zone = var.az1 key_name = var.keyname user_data = data.template_file.FortiGate.rendered root_block_device { volume_type = "standard" volume_size = "2" } ebs_block_device { device_name = "/dev/sdb" volume_size = "30" volume_type = "standard" } network_interface { network_interface_id = aws_network_interface.eth0.id device_index = 0 } network_interface { network_interface_id = aws_network_interface.eth1.id device_index = 1 } tags = { Name = "FortiGateVM" } } data "template_file" "FortiGate" { template = "${file("${var.bootstrap-fgtvm}")}" vars = { type = "${var.license_type}" license_file = "${var.license}" adminsport = "${var.adminsport}" } } FortiGateのインタフェース設 定とサブネットを紐付け。 インスタンスタイプの設定。 ライセンス(BYOLかPAYGか)も ここで。 BYOLの場合はライセンスファイルを 同じディレクトリ上に置いておく。 // AMIs are for FGTVM AWS(BYOL) - 7.0.1 variable "fgtvmbyolami" { type = map default = { us-west-2 = "ami-0070ab4edc735c379" us-west-1 = "ami-09e5387cc293153c1" us-east-1 = "ami-02678839ab63d47a1" us-east-2 = "ami-01fc50db5a27388fa" ap-east-1 = "ami-069022a0b0042e2b8" ap-south-1 = "ami-00609a13c17b3cf5d" ap-northeast-2 = "ami-0a0e4c41637e6936f" ap-southeast-1 = "ami-0d9a129903b7ba964" ap-southeast-2 = "ami-0b9ef7623fc628069" ap-northeast-1 = "ami-0bfb0a297a846758d" ca-central-1 = "ami-0f5966c7ff86c1cb6" eu-central-1 = "ami-09ca8648996694d40" eu-west-1 = "ami-01118ca5692326739" eu-west-2 = "ami-073e5153688b42f25" eu-west-3 = "ami-00e8ba0a04789ad0e" eu-north-1 = "ami-0907f64a7bbfb94ff" me-south-1 = "ami-098b025df177bd3d4" sa-east-1 = "ami-01abe8a3a6cd165e7" } } variable "bootstrap-fgtvm" { // Change to your own path type = string default = "fgtvm.conf" } // license file for the active fgt variable "license" { // Change to your own byol license file, license.lic type = string default = "FGVM32TM21000248.lic" } イメージ(FortiOS)のIDは変数 として定義済み。 fgtvm.tf variables.tf FortiGateの初期設定を別 ファイルで⽤意。