resource "aws_subnet" "new_subnet" {
vpc_id = "${var.vpc_id}"
cidr_block = "10.0.2.0/24"
tags = {
Name = "new_subnet"
}
}
resource "aws_nat_gateway" "nat_gateway" {
allocation_id = "${aws_eip.nat_eip.id}"
subnet_id = "${aws_subnet.new_subnet.id}"
depends_on = ["aws_internet_gateway.main"]
}
resource "aws_eip" "nat_eip" {
vpc = true
depends_on = ["aws_internet_gateway.main"]
}
resource "aws_security_group" "nfs-outbound" {
name_prefix = "nfs-outbound"
vpc_id = "${var.vpc_id}"
egress {
from_port = 2049
to_port = 2049
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
注意:示例中的 ${var.vpc_id} 需要替换为您实际的 VPC ID。