resource "aws_eip" "lb" {
instance = aws_instance.web.id
vpc = true
}
resource "aws_nat_gateway" "example" {
allocation_id = aws_eip.example.id
subnet_id = aws_subnet.example.id
tags = {
Name = "gw NAT"
}
# EIP 받아오기
resource "aws_eip" "nat-2a" {
vpc = true
}
resource "aws_eip" "nat-2c" {
vpc = true
}
resource "aws_nat_gateway" "natgw-2a" {
allocation_id = aws_eip.nat-2a.id
subnet_id = aws_subnet.sub-pub1-10-10-1-0.id
tags = {
Name = "gw NAT-2a"
}
}
resource "aws_nat_gateway" "natgw-2c" {
allocation_id = aws_eip.nat-2c.id
subnet_id = aws_subnet.sub-pub2-10-10-2-0.id
tags = {
Name = "gw NAT-2c"
}
}
- EIP를 생성한 뒤 NAT-gateway에는 EIP가 필요하기 떄문에 NAT gateway 생성 시 EIP를 넣어주는 구문이다.
728x90
'Cloud > Terraform' 카테고리의 다른 글
Terraform - Private Subnet에 Application Load Balancer 구성 (0) | 2022.07.09 |
---|---|
Terraform - Bastion host 생성 및 Private EC2 액세스 (0) | 2022.07.09 |
Terraform - Private subnet용 Route table 구성 (0) | 2022.07.09 |
Terraform - Internet Gateway 생성 및 Public subnet용 Route table 구성 (0) | 2022.07.09 |
Terraform - Public subnet 및 Private subnet 생성 (0) | 2022.07.09 |