diff --git a/modules/route-add/main.tf b/modules/route-add/main.tf index 6d4e9ae..c312568 100644 --- a/modules/route-add/main.tf +++ b/modules/route-add/main.tf @@ -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] diff --git a/modules/route-add/variables.tf b/modules/route-add/variables.tf index ec55e3f..7dfddfd 100644 --- a/modules/route-add/variables.tf +++ b/modules/route-add/variables.tf @@ -1,9 +1,4 @@ -variable "vpc_id" { - description = "set vpc id" - type = string -} - -variable "tag_name" { +variable "route_public_id" { description = "value" type = string } diff --git a/modules/route-association/main.tf b/modules/route-association/main.tf index e69de29..d4764f7 100644 --- a/modules/route-association/main.tf +++ b/modules/route-association/main.tf @@ -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 +} \ No newline at end of file diff --git a/modules/route-association/variables.tf b/modules/route-association/variables.tf index e69de29..e3a793c 100644 --- a/modules/route-association/variables.tf +++ b/modules/route-association/variables.tf @@ -0,0 +1,9 @@ +variable "subnet_ids" { + description = "Subnet id" + type = list +} + +variable "route_table_id" { + description = "Subnet id" + type = string +} \ No newline at end of file diff --git a/prod/main.tf b/prod/main.tf index 4b60495..0b5435d 100644 --- a/prod/main.tf +++ b/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" { diff --git a/prod/valiables.tf b/prod/valiables.tf index 2761f67..f9736a1 100644 --- a/prod/valiables.tf +++ b/prod/valiables.tf @@ -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"