العودة إلى الدورة

الجمل الشرطية: If/Else في IaC

احتراف البنية التحتية كبرمجيات (Terraform & OpenTofu)

Making Decisions

Sometimes you only want to create a resource in Production, not in Development.

hcl variable "is_production" { type = bool }

resource "aws_instance" "db" { count = var.is_production ? 1 : 0

... settings ...

}

This uses the Ternary Operator. If is_production is true, count is 1. If false, count is 0 (resource not created).