route table 추가 환경변경

This commit is contained in:
2023-01-13 02:55:31 +09:00
parent e9c35f55b5
commit d3f56ecc0c
20 changed files with 274 additions and 201 deletions

View File

@ -1,16 +1,26 @@
resource "aws_route" "route-igw-add" {
count = format("%.1s", var.gw_type) == "i" ? 1 : 0
route_table_id = var.route_id
destination_cidr_block = "0.0.0.0/0"
destination_cidr_block = var.destination_cidr
gateway_id = var.igw_id
depends_on = [var.route_id]
# depends_on = [aws_route_table.testing]
}
resource "aws_route" "route-nat-add" {
count = format("%.1s", var.gw_type) == "i" ? 0 : 1
count = format("%.1s", var.gw_type) == "n" ? 1 : 0
route_table_id = var.route_id
destination_cidr_block = "0.0.0.0/0"
destination_cidr_block = var.destination_cidr
nat_gateway_id = var.nat_id
depends_on = [var.route_id]
# depends_on = [aws_route_table.testing]
}
# transit_gateway_id -
resource "aws_route" "route-tgw-add" {
count = format("%.1s", var.gw_type) == "t" ? 1 : 0
route_table_id = var.route_id
destination_cidr_block = var.destination_cidr
# "10.0.0.0/8"
transit_gateway_id = var.tgw_id
depends_on = [var.route_id]
}

View File

@ -1,3 +1,8 @@
variable "destination_cidr" {
description = "destination cidr"
type = string
}
variable "route_id" {
description = "value"
type = string
@ -16,4 +21,10 @@ variable "nat_id" {
description = "value"
type = string
default = "null"
}
variable "tgw_id" {
description = "value"
type = string
default = "null"
}

View File

@ -7,7 +7,7 @@
resource "aws_route_table" "rt-tbl" {
vpc_id = var.vpc_id
tags = {
Name = "${var.tag_name}-route-public"
Name = "${var.tag_name}"
}
# route {

View File

@ -0,0 +1,6 @@
resource "aws_ec2_transit_gateway" "tgw" {
description = "tgw"
tags = {
Name = "${var.tag_name}"
}
}

View File

@ -0,0 +1,3 @@
output "tgw_id" {
value = aws_ec2_transit_gateway.tgw.id
}

View File

@ -0,0 +1,5 @@
variable "tag_name" {
description = "tag_name"
type = string
}

View File

@ -0,0 +1,5 @@
resource "aws_ec2_transit_gateway_vpc_attachment" "tgw-vpc-attatch" {
subnet_ids = var.subnet_id_list
transit_gateway_id = var.tgw_id
vpc_id = var.vpc_id
}

View File

@ -0,0 +1,14 @@
variable "subnet_id_list" {
description = "subnet_id_list"
type = list(string)
}
variable "tgw_id" {
description = "tgw_id"
type = string
}
variable "vpc_id" {
description = "vpc_id"
type = string
}