output 변수 테스트
This commit is contained in:
parent
c79a4c9c29
commit
72fb5351b6
24
01-start/.terraform.lock.hcl
Normal file
24
01-start/.terraform.lock.hcl
Normal file
@ -0,0 +1,24 @@
|
||||
# This file is maintained automatically by "terraform init".
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.terraform.io/hashicorp/aws" {
|
||||
version = "4.48.0"
|
||||
hashes = [
|
||||
"h1:8xLCA04IhQUzGI8/t3ySKNFMyjgGCWiXRUWhWEsYvew=",
|
||||
"zh:08f5e3c5256a4fbd5c988863d10e5279172b2470fec6d4fb13c372663e7f7cac",
|
||||
"zh:2a04376b7fa84681bd2938973c7d0822c8c0f0656a4e7661a2f50ac4d852d4a3",
|
||||
"zh:30d6cdf321aaba874934cbde505333d89d172d8d5ffcf40b6e66626c57bc6ab2",
|
||||
"zh:364639ee19cf4cfaa65de84a2a71d32725d5b728b71dd88d01ccb639c006c1cf",
|
||||
"zh:4e02252cd88b6f59f556f49c5ce46a358046c98f069230358ac15f4030ae1e76",
|
||||
"zh:611717320f20b3512ceb90abddd5198a85e1093965ce59e3ef8183188c84f8c3",
|
||||
"zh:630be3b9ba5b3a95ecb2ce2f3523714ab37cd8bcd7479c879a769e6a446ab5ed",
|
||||
"zh:6701f9d3ae1ffadb3ebefbe75c9d82668cc5495b8f826e498adb8530e202b652",
|
||||
"zh:6dc6fdfa7469c9de7b405c68b2f6a09a3438db1ef09d348e49c7ceff4300b01a",
|
||||
"zh:84c8140d8af6965fa9cd80e52eb2ee3d273e3ab7762719a8d1af665c08fab748",
|
||||
"zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425",
|
||||
"zh:9b6b4f7d4cea37ba7a42a47d506115498858bcd6440ad97dfb214c13a688ba90",
|
||||
"zh:a7f876af20f5c5dae8e333ec0dfc901e26aa801137e7df65fb365565637bbfe2",
|
||||
"zh:ad107b8e11dd0609b856584ce70ae6621aa4f1f946da51f7c792f1259e3f9c27",
|
||||
"zh:d5dc1683693a5fe2652952f50dbbeccd02716799c26c6d1a1378b226cf845e9b",
|
||||
]
|
||||
}
|
1
01-start/bar.txt
Normal file
1
01-start/bar.txt
Normal file
@ -0,0 +1 @@
|
||||
sdjo
|
14
01-start/main.tf
Normal file
14
01-start/main.tf
Normal file
@ -0,0 +1,14 @@
|
||||
provider "aws" {
|
||||
region = "ap-northeast-2"
|
||||
}
|
||||
|
||||
|
||||
|
||||
resource "aws_instance" "ubuntu" {
|
||||
ami = "ami-0ab04b3ccbadfae1f"
|
||||
instance_type = "t2.micro"
|
||||
|
||||
tags = {
|
||||
Name = "tf-ubuntu"
|
||||
}
|
||||
}
|
8
modules/ec2/main.tf
Normal file
8
modules/ec2/main.tf
Normal file
@ -0,0 +1,8 @@
|
||||
resource "aws_instance" "ubuntu" {
|
||||
ami = "ami-0ab04b3ccbadfae1f"
|
||||
instance_type = "t2.micro"
|
||||
|
||||
tags = {
|
||||
Name = "tf-ubuntu"
|
||||
}
|
||||
}
|
@ -1,7 +1,10 @@
|
||||
//라우팅 테이블 서브넷 연결
|
||||
resource "aws_route_table_association" "route-association" {
|
||||
for_each = toset(var.subnet_ids)
|
||||
subnet_id = each.value
|
||||
|
||||
# for_each = toset(var.subnet_ids)
|
||||
# subnet_id = each.value
|
||||
count = var.association_count
|
||||
subnet_id = var.subnet_ids[count.index]
|
||||
route_table_id = var.route_table_id
|
||||
|
||||
|
||||
}
|
@ -1,9 +1,15 @@
|
||||
variable "subnet_ids" {
|
||||
description = "Subnet id"
|
||||
type = list
|
||||
description = "Subnet id"
|
||||
type = list(any)
|
||||
}
|
||||
|
||||
variable "route_table_id" {
|
||||
description = "Subnet id"
|
||||
type = string
|
||||
}
|
||||
description = "Subnet id"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "association_count" {
|
||||
description = "Subnet count"
|
||||
type = number
|
||||
}
|
||||
|
||||
|
@ -6,10 +6,10 @@ resource "aws_subnet" "subnets" {
|
||||
availability_zone = each.value.name
|
||||
cidr_block = each.value.cidr
|
||||
|
||||
map_public_ip_on_launch = true
|
||||
map_public_ip_on_launch = var.public_ip_on
|
||||
|
||||
tags = {
|
||||
Name = "${var.vpc_id}-${each.value.name}"
|
||||
Name = var.vpc_name
|
||||
# Name = module.vpc_hq.vpcHq.id
|
||||
}
|
||||
}
|
@ -3,6 +3,11 @@ variable "vpc_id" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "vpc_name" {
|
||||
description = "set vpc name"
|
||||
type = string
|
||||
}
|
||||
|
||||
// reference | https://github.com/davidcsi/terraform/blob/master/healthchecks/main.tf
|
||||
variable "subnet-az-list" {
|
||||
description = "Subnet available zone & cidr"
|
||||
@ -25,5 +30,8 @@ variable "subnet-az-list" {
|
||||
# cidr = "10.3.4.0/24"
|
||||
# }
|
||||
# }
|
||||
|
||||
}
|
||||
|
||||
variable "public_ip_on" {
|
||||
type = bool
|
||||
}
|
@ -2,4 +2,9 @@
|
||||
output "vpc_hq_id" {
|
||||
description = "The name of vpc hq id"
|
||||
value = aws_vpc.vpc-hq.id
|
||||
}
|
||||
}
|
||||
|
||||
output "vpc_name" {
|
||||
value = var.tag_name
|
||||
}
|
||||
|
||||
|
56
prod/main.tf
56
prod/main.tf
@ -1,55 +1,59 @@
|
||||
// prod - main
|
||||
|
||||
provider "aws" {
|
||||
region = "ap-northeast-2"
|
||||
region = "ap-northeast-2"
|
||||
|
||||
#2.x버전의 AWS공급자 허용
|
||||
version = "~> 2.0"
|
||||
|
||||
#2.x버전의 AWS공급자 허용
|
||||
version = "~> 2.0"
|
||||
|
||||
}
|
||||
|
||||
# module "vpc_hq" {
|
||||
module "vpc_hq" {
|
||||
source = "../modules/vpc"
|
||||
tag_name = var.prod_name
|
||||
cidr_block = "10.3.0.0/16"
|
||||
|
||||
source = "../modules/vpc"
|
||||
# source = "github.com/Seong-dong/team_prj/tree/main/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
|
||||
source = "../modules/igw"
|
||||
tag_name = var.prod_name
|
||||
vpc_id = module.vpc_hq.vpc_hq_id
|
||||
}
|
||||
|
||||
module "subnet_list" {
|
||||
source = "../modules/vpc-subnet"
|
||||
module "subnet_public" {
|
||||
source = "../modules/vpc-subnet"
|
||||
|
||||
vpc_id = module.vpc_hq.vpc_hq_id
|
||||
subnet-az-list = var.subnet-az-list
|
||||
vpc_id = module.vpc_hq.vpc_hq_id
|
||||
subnet-az-list = var.subnet-az-list
|
||||
public_ip_on = true
|
||||
vpc_name = "${module.vpc_hq.vpc_name}-public"
|
||||
}
|
||||
|
||||
// public route
|
||||
module "route_public" {
|
||||
source = "../modules/route-table"
|
||||
tag_name = var.prod_name
|
||||
vpc_id = module.vpc_hq.vpc_hq_id
|
||||
|
||||
source = "../modules/route-table"
|
||||
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
|
||||
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]
|
||||
|
||||
source = "../modules/route-association"
|
||||
route_table_id = module.route_public.route_public_id
|
||||
|
||||
association_count = 2
|
||||
subnet_ids = [module.subnet_public.subnet.zone-a.id, module.subnet_public.subnet.zone-c.id]
|
||||
}
|
||||
|
||||
# EKS테스트 할때 활성
|
||||
# module "ecr" {
|
||||
# source = "../modules/ecr"
|
||||
|
@ -1,5 +1,5 @@
|
||||
//modules-subnet-outputs
|
||||
output "subnet" {
|
||||
description = "The name of vpc hq id"
|
||||
value = module.subnet_list.subnet
|
||||
}
|
||||
value = module.subnet_public.subnet
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
# variable "cidr_block" {
|
||||
# type = string
|
||||
# default = "10.3.0.0/16"
|
||||
|
||||
|
||||
# }
|
||||
|
||||
variable "prod_name" {
|
||||
description = "value"
|
||||
type = string
|
||||
default = "22shop"
|
||||
description = "value"
|
||||
type = string
|
||||
default = "22shop"
|
||||
}
|
||||
|
||||
# variable "igw_id" {
|
||||
@ -16,25 +16,25 @@ variable "prod_name" {
|
||||
# }
|
||||
|
||||
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"
|
||||
}
|
||||
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