كتابة ملفات أداة Terraform
من الطرق المساعدة لإخبار Terraform أنه يجب حذف بعض الموارد حتى عندما لا يوجد اعتمادية مباشرة عليها
- 1.الوسيط
index_document
هو وسيط إجباري يجب تحديده، إذا كانتvar.website
ليستmap
فارغة - 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