Links
Comment on page

Terraform 구성(configurations) 작성하기

locals를 사용해 리소스 간의 명시적 의존성 지정하기

Terraform 구성(configurations)에 직접적인 의존성이 없는 경우에도 특정 리소스가 삭제되어야 함을 Terraform에 알려주는 유용한 방법입니다.

Terraform 0.12 - 필수적 vs 선택적 인수

  1. 1.
    var.website가 빈 맵이 아닌 경우 필수적 인수 index_document를 반드시 설정해야 합니다.
  2. 2.
    선택적 인수 error_document는 생략할 수 있습니다.
main.tf
variable "website" {
type = map(string)
default = {}
}
resource "aws_s3_bucket" "this" {
# omitted...
dynamic "website" {
for_each = length(keys(var.website)) == 0 ? [] : [var.website]
content {
index_document = website.value.index_document
error_document = lookup(website.value, "error_document", null)
}
}
}
terraform.tfvars
website = {
index_document = "index.html"
}