Count를 사용한 Resource 생성
Count를 사용하면 특정 리소스를 여러 개 생성할 수 있다.
Resource 정의
resource "aws_instance" "example" {
count = 3 # 인스턴스를 3개 생성
ami = "ami-12345678"
instance_type = "t2.micro"
tags = {
Name = "example-instance-${count.index}"
}
}
count = 3
:aws_instance
리소스 3개 생성${count.index}
: 0부터 시작하는 인덱스, 각 리소스마다 고유한 값을 가진다
'IaC👩💻 > TerraForm' 카테고리의 다른 글
[TerraForm] 상태저장소(backend)와 상태관리(state) 개념 (0) | 2024.08.23 |
---|---|
[Terraform] 조건문 (0) | 2024.08.23 |
[TerraForm] Outputs (0) | 2024.08.23 |
[TerraForm] Local (0) | 2024.08.23 |
[TerraForm] variable (0) | 2024.08.23 |