igw 생성.
This commit is contained in:
parent
535d721a50
commit
89ee20efff
@ -2,6 +2,6 @@ resource "aws_internet_gateway" "gw" {
|
||||
vpc_id = var.vpc_id
|
||||
|
||||
tags = {
|
||||
Name = "main-igw"
|
||||
Name = "${var.tag_name}-igw"
|
||||
}
|
||||
}
|
5
modules/igw/outputs.tf
Normal file
5
modules/igw/outputs.tf
Normal file
@ -0,0 +1,5 @@
|
||||
//modules-igw-output
|
||||
output "igw_id" {
|
||||
description = "The name of hq-igw id"
|
||||
value = aws_internet_gateway.gw.id
|
||||
}
|
@ -1,4 +1,9 @@
|
||||
variable "vpc_id" {
|
||||
description = "set vpc id"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "tag_name" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
7
modules/route-add/main.tf
Normal file
7
modules/route-add/main.tf
Normal file
@ -0,0 +1,7 @@
|
||||
resource "aws_route" "r" {
|
||||
route_table_id = "rtb-4fbb3ac4"
|
||||
destination_cidr_block = "0.0.0.0/0"
|
||||
gateway_id = var.igw_id
|
||||
depends_on = [var.route_public_id]
|
||||
# depends_on = [aws_route_table.testing]
|
||||
}
|
14
modules/route-add/variables.tf
Normal file
14
modules/route-add/variables.tf
Normal file
@ -0,0 +1,14 @@
|
||||
variable "vpc_id" {
|
||||
description = "set vpc id"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "tag_name" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "igw_id" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
0
modules/route-association/variables.tf
Normal file
0
modules/route-association/variables.tf
Normal file
24
modules/route-table/main.tf
Normal file
24
modules/route-table/main.tf
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
라우팅 테이블에 서브넷을 연결.
|
||||
라우팅에서 경로 설정.
|
||||
*/
|
||||
|
||||
//public
|
||||
resource "aws_route_table" "public-table" {
|
||||
vpc_id = var.vpc_id
|
||||
tags = {
|
||||
Name = "${var.tag_name}-route-public"
|
||||
}
|
||||
|
||||
# route {
|
||||
# cidr_block = "10.0.1.0/24"
|
||||
# gateway_id = aws_internet_gateway.example.id
|
||||
# }
|
||||
|
||||
# route {
|
||||
# ipv6_cidr_block = "::/0"
|
||||
# egress_only_gateway_id = aws_egress_only_internet_gateway.example.id
|
||||
# }
|
||||
}
|
||||
|
||||
//private
|
5
modules/route-table/outputs.tf
Normal file
5
modules/route-table/outputs.tf
Normal file
@ -0,0 +1,5 @@
|
||||
output "route_public_id" {
|
||||
description = "get route_public_id"
|
||||
value = aws_route_table.public-table.id
|
||||
|
||||
}
|
9
modules/route-table/variables.tf
Normal file
9
modules/route-table/variables.tf
Normal file
@ -0,0 +1,9 @@
|
||||
variable "vpc_id" {
|
||||
description = "set vpc id"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "tag_name" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
0
modules/templates/main.tf
Normal file
0
modules/templates/main.tf
Normal file
0
modules/templates/outputs.tf
Normal file
0
modules/templates/outputs.tf
Normal file
0
modules/templates/variables.tf
Normal file
0
modules/templates/variables.tf
Normal file
@ -0,0 +1,5 @@
|
||||
//modules-subnet-outputs
|
||||
output "subnet" {
|
||||
description = "The name of vpc hq id"
|
||||
value = aws_subnet.subnets
|
||||
}
|
@ -9,6 +9,6 @@ resource "aws_vpc" "vpc-hq" {
|
||||
|
||||
|
||||
tags = {
|
||||
Name = "test"
|
||||
Name = "${var.tag_name}-vpc"
|
||||
}
|
||||
}
|
@ -2,4 +2,7 @@ variable "cidr_block" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "tag_name" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
||||
|
BIN
ppt작업.pptx
Normal file
BIN
ppt작업.pptx
Normal file
Binary file not shown.
39
prod/main.tf
39
prod/main.tf
@ -11,14 +11,14 @@ provider "aws" {
|
||||
# module "vpc_hq" {
|
||||
module "vpc_hq" {
|
||||
source = "../modules/vpc"
|
||||
|
||||
tag_name = var.prod_name
|
||||
cidr_block = "10.3.0.0/16"
|
||||
|
||||
}
|
||||
|
||||
module "vpc_igw" {
|
||||
source = "../modules/igw"
|
||||
|
||||
tag_name = var.prod_name
|
||||
vpc_id = module.vpc_hq.vpc_hq_id
|
||||
}
|
||||
|
||||
@ -26,29 +26,20 @@ module "subnet_list" {
|
||||
source = "../modules/vpc-subnet"
|
||||
|
||||
vpc_id = module.vpc_hq.vpc_hq_id
|
||||
subnet-az-list = {
|
||||
"zone-a" = {
|
||||
name = "ap-northeast-2a"
|
||||
cidr = "10.3.1.0/24"
|
||||
}
|
||||
"zone-b" = {
|
||||
name = "ap-northeast-2b"
|
||||
cidr = "10.3.2.0/24"
|
||||
}
|
||||
"zone-c" = {
|
||||
name = "ap-northeast-2c"
|
||||
cidr = "10.3.3.0/24"
|
||||
}
|
||||
"zone-d" = {
|
||||
name = "ap-northeast-2d"
|
||||
cidr = "10.3.4.0/24"
|
||||
}
|
||||
}
|
||||
subnet-az-list = var.subnet-az-list
|
||||
}
|
||||
|
||||
module "ecr" {
|
||||
source = "../modules/ecr"
|
||||
|
||||
names_list = ["web", "nginx", "mariadb"]
|
||||
// public route
|
||||
module "route_public" {
|
||||
source = "../modules/route-table"
|
||||
tag_name = var.prod_name
|
||||
vpc_id = module.vpc_hq.vpc_hq_id
|
||||
|
||||
}
|
||||
# EKS테스트 할때 활성
|
||||
# module "ecr" {
|
||||
# source = "../modules/ecr"
|
||||
|
||||
# names_list = ["web", "nginx", "mariadb"]
|
||||
# }
|
||||
|
||||
|
@ -0,0 +1,5 @@
|
||||
//modules-subnet-outputs
|
||||
output "subnet" {
|
||||
description = "The name of vpc hq id"
|
||||
value = module.subnet_list.subnet
|
||||
}
|
@ -2,4 +2,39 @@
|
||||
# type = string
|
||||
# default = "10.3.0.0/16"
|
||||
|
||||
# }
|
||||
# }
|
||||
|
||||
variable "prod_name" {
|
||||
description = "value"
|
||||
type = string
|
||||
default = "22shop"
|
||||
}
|
||||
|
||||
variable "igw_id" {
|
||||
description = "value"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "subnet-az-list" {
|
||||
description = "Subnet available zone & cidr"
|
||||
type = map(map(string))
|
||||
default = {
|
||||
"zone-a" = {
|
||||
name = "ap-northeast-2a"
|
||||
cidr = "10.3.1.0/24"
|
||||
}
|
||||
"zone-b" = {
|
||||
name = "ap-northeast-2b"
|
||||
cidr = "10.3.2.0/24"
|
||||
}
|
||||
"zone-c" = {
|
||||
name = "ap-northeast-2c"
|
||||
cidr = "10.3.3.0/24"
|
||||
}
|
||||
"zone-d" = {
|
||||
name = "ap-northeast-2d"
|
||||
cidr = "10.3.4.0/24"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user