# Original teaching fixture. Terraform 1.4+; no external provider or cloud API.
# Run only in a new disposable directory containing this file as main.tf.
terraform {
  required_version = ">= 1.4, < 2.0"
}

variable "replicas" {
  type    = number
  default = 2
  validation {
    condition     = var.replicas >= 1 && var.replicas <= 4 && floor(var.replicas) == var.replicas
    error_message = "Use a whole number from one through four in this local example."
  }
}

# terraform_data stores a value in Terraform state. It does NOT create servers.
resource "terraform_data" "service_contract" {
  input = {
    service  = "fictional-field-desk"
    replicas = var.replicas
  }
}

output "declared_contract" {
  value = terraform_data.service_contract.output
}
