output 변수 테스트

This commit is contained in:
2022-12-27 23:18:58 +09:00
parent c79a4c9c29
commit 72fb5351b6
12 changed files with 138 additions and 65 deletions

8
modules/ec2/main.tf Normal file
View File

@ -0,0 +1,8 @@
resource "aws_instance" "ubuntu" {
ami = "ami-0ab04b3ccbadfae1f"
instance_type = "t2.micro"
tags = {
Name = "tf-ubuntu"
}
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}
}

View File

@ -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
}

View File

@ -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
}