Comment on page
Terraform 구성(configurations) 작성하기
Terraform 구성(configurations)에 직접적인 의존성이 없는 경우에도 특정 리소스가 삭제되어야 함을 Terraform에 알려주는 유용한 방법입니다.
- 1.
var.website
가 빈 맵이 아닌 경우 필수적 인수index_document
를 반드시 설정해야 합니다. - 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"
}
Last modified 1mo ago