diff --git a/modules/igw/main.tf b/modules/igw/main.tf index cf95d66..5fd0dd1 100644 --- a/modules/igw/main.tf +++ b/modules/igw/main.tf @@ -2,6 +2,6 @@ resource "aws_internet_gateway" "gw" { vpc_id = var.vpc_id tags = { - Name = "main-igw" + Name = "${var.tag_name}-igw" } } \ No newline at end of file diff --git a/modules/igw/outputs.tf b/modules/igw/outputs.tf new file mode 100644 index 0000000..8efa749 --- /dev/null +++ b/modules/igw/outputs.tf @@ -0,0 +1,5 @@ +//modules-igw-output +output "igw_id" { + description = "The name of hq-igw id" + value = aws_internet_gateway.gw.id +} \ No newline at end of file diff --git a/modules/igw/valiables.tf b/modules/igw/valiables.tf index ca81c1f..1b6592e 100644 --- a/modules/igw/valiables.tf +++ b/modules/igw/valiables.tf @@ -1,4 +1,9 @@ variable "vpc_id" { description = "set vpc id" type = string +} + +variable "tag_name" { + description = "value" + type = string } \ No newline at end of file diff --git a/modules/route-add/main.tf b/modules/route-add/main.tf new file mode 100644 index 0000000..6d4e9ae --- /dev/null +++ b/modules/route-add/main.tf @@ -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] +} \ No newline at end of file diff --git a/modules/outputs.tf b/modules/route-add/outputs.tf similarity index 100% rename from modules/outputs.tf rename to modules/route-add/outputs.tf diff --git a/modules/route-add/variables.tf b/modules/route-add/variables.tf new file mode 100644 index 0000000..ec55e3f --- /dev/null +++ b/modules/route-add/variables.tf @@ -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 +} \ No newline at end of file diff --git a/modules/main.tf b/modules/route-association/main.tf similarity index 100% rename from modules/main.tf rename to modules/route-association/main.tf diff --git a/modules/valiables.tf b/modules/route-association/outputs.tf similarity index 100% rename from modules/valiables.tf rename to modules/route-association/outputs.tf diff --git a/modules/route-association/variables.tf b/modules/route-association/variables.tf new file mode 100644 index 0000000..e69de29 diff --git a/modules/route-table/main.tf b/modules/route-table/main.tf new file mode 100644 index 0000000..cbf23eb --- /dev/null +++ b/modules/route-table/main.tf @@ -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 \ No newline at end of file diff --git a/modules/route-table/outputs.tf b/modules/route-table/outputs.tf new file mode 100644 index 0000000..805a9ad --- /dev/null +++ b/modules/route-table/outputs.tf @@ -0,0 +1,5 @@ +output "route_public_id" { + description = "get route_public_id" + value = aws_route_table.public-table.id + +} \ No newline at end of file diff --git a/modules/route-table/variables.tf b/modules/route-table/variables.tf new file mode 100644 index 0000000..1b6592e --- /dev/null +++ b/modules/route-table/variables.tf @@ -0,0 +1,9 @@ +variable "vpc_id" { + description = "set vpc id" + type = string +} + +variable "tag_name" { + description = "value" + type = string +} \ No newline at end of file diff --git a/modules/templates/main.tf b/modules/templates/main.tf new file mode 100644 index 0000000..e69de29 diff --git a/modules/templates/outputs.tf b/modules/templates/outputs.tf new file mode 100644 index 0000000..e69de29 diff --git a/modules/templates/variables.tf b/modules/templates/variables.tf new file mode 100644 index 0000000..e69de29 diff --git a/modules/vpc-subnet/outputs.tf b/modules/vpc-subnet/outputs.tf index e69de29..b292b09 100644 --- a/modules/vpc-subnet/outputs.tf +++ b/modules/vpc-subnet/outputs.tf @@ -0,0 +1,5 @@ +//modules-subnet-outputs +output "subnet" { + description = "The name of vpc hq id" + value = aws_subnet.subnets +} \ No newline at end of file diff --git a/modules/vpc/main.tf b/modules/vpc/main.tf index 15c0e7e..420d28f 100644 --- a/modules/vpc/main.tf +++ b/modules/vpc/main.tf @@ -9,6 +9,6 @@ resource "aws_vpc" "vpc-hq" { tags = { - Name = "test" + Name = "${var.tag_name}-vpc" } } \ No newline at end of file diff --git a/modules/vpc/valiables.tf b/modules/vpc/valiables.tf index b95191d..54f3314 100644 --- a/modules/vpc/valiables.tf +++ b/modules/vpc/valiables.tf @@ -2,4 +2,7 @@ variable "cidr_block" { description = "value" type = string } - +variable "tag_name" { + description = "value" + type = string +} diff --git a/ppt작업.pptx b/ppt작업.pptx new file mode 100644 index 0000000..7cf34b9 Binary files /dev/null and b/ppt작업.pptx differ diff --git a/prod/main.tf b/prod/main.tf index 896df21..4b60495 100644 --- a/prod/main.tf +++ b/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"] +# } diff --git a/prod/outputs.tf b/prod/outputs.tf index e69de29..d5e9978 100644 --- a/prod/outputs.tf +++ b/prod/outputs.tf @@ -0,0 +1,5 @@ +//modules-subnet-outputs +output "subnet" { + description = "The name of vpc hq id" + value = module.subnet_list.subnet +} \ No newline at end of file diff --git a/prod/valiables.tf b/prod/valiables.tf index 00caba5..2761f67 100644 --- a/prod/valiables.tf +++ b/prod/valiables.tf @@ -2,4 +2,39 @@ # type = string # default = "10.3.0.0/16" -# } \ No newline at end of file +# } + +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" + } + } + +} \ No newline at end of file