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

قوة الـ Count: توسيع الموارد

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

Creating 100 Servers with 1 Line

Need more than one server? Don't copy-paste code. Use count.

hcl resource "aws_instance" "web" { count = 3 ami = "ami-xyz" instance_type = "t2.micro"

tags = { Name = "Server-${count.index}" } }

This creates 3 servers named Server-0, Server-1, and Server-2. If you change count to 0, it destroys all of them.