라우팅테이블 서브넷 리스트 할당 연결
This commit is contained in:
parent
89ee20efff
commit
c79a4c9c29
@ -1,5 +1,5 @@
|
||||
resource "aws_route" "r" {
|
||||
route_table_id = "rtb-4fbb3ac4"
|
||||
resource "aws_route" "route-add" {
|
||||
route_table_id = var.route_public_id
|
||||
destination_cidr_block = "0.0.0.0/0"
|
||||
gateway_id = var.igw_id
|
||||
depends_on = [var.route_public_id]
|
||||
|
@ -1,9 +1,4 @@
|
||||
variable "vpc_id" {
|
||||
description = "set vpc id"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "tag_name" {
|
||||
variable "route_public_id" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
//라우팅 테이블 서브넷 연결
|
||||
resource "aws_route_table_association" "route-association" {
|
||||
for_each = toset(var.subnet_ids)
|
||||
subnet_id = each.value
|
||||
|
||||
route_table_id = var.route_table_id
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
variable "subnet_ids" {
|
||||
description = "Subnet id"
|
||||
type = list
|
||||
}
|
||||
|
||||
variable "route_table_id" {
|
||||
description = "Subnet id"
|
||||
type = string
|
||||
}
|
14
prod/main.tf
14
prod/main.tf
@ -35,6 +35,20 @@ module "route_public" {
|
||||
tag_name = var.prod_name
|
||||
vpc_id = module.vpc_hq.vpc_hq_id
|
||||
|
||||
}
|
||||
|
||||
module "route_add" {
|
||||
source = "../modules/route-add"
|
||||
route_public_id = module.route_public.route_public_id
|
||||
igw_id = module.vpc_igw.igw_id
|
||||
}
|
||||
|
||||
module "route_association" {
|
||||
source = "../modules/route-association"
|
||||
route_table_id = module.route_public.route_public_id
|
||||
subnet_ids = [module.subnet_list.subnet.zone-a.id, module.subnet_list.subnet.zone-c.id]
|
||||
|
||||
|
||||
}
|
||||
# EKS테스트 할때 활성
|
||||
# module "ecr" {
|
||||
|
@ -10,10 +10,10 @@ variable "prod_name" {
|
||||
default = "22shop"
|
||||
}
|
||||
|
||||
variable "igw_id" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
||||
# variable "igw_id" {
|
||||
# description = "value"
|
||||
# type = string
|
||||
# }
|
||||
|
||||
variable "subnet-az-list" {
|
||||
description = "Subnet available zone & cidr"
|
||||
|
Loading…
Reference in New Issue
Block a user