Day 7: Type Constraints in Terraform
1. Primitives Terraform offers three primitive types: string , number , and boolean . These are the building blocks for simpler data definitions. String Example: A string is used for text data. variable "region" { type = string description = "AWS region" } In your terraform.tfvars , you define the value: region = "us-west-2" In your resource definition ( main.tf ), you use the string: resource "aws_instance" "web_server" { ami = "ami-0e8459476fed2e23b" instance_type = "t2.micro" count = var.instance_count # number region = var.region # string } Number Example: A number is used for numerical data, such as counts or sizes. variable "instance_count" { type = number description = "Number of EC2 instances to create" } In terraform.tfvars , you define: instance_count = 2 Then, in your main.tf : resource ...