terraform {
  required_version = "~> 1.13.0"
}

variable "replicas" {
  type    = number
  default = 2
  validation {
    condition     = var.replicas >= 1 && floor(var.replicas) == var.replicas
    error_message = "replicas must be a positive integer."
  }
}

# Built-in resource only: planning does not create infrastructure.
resource "terraform_data" "spec" {
  input = {
    replicas = var.replicas
    port     = 8080
  }
  lifecycle {
    prevent_destroy = true
  }
}

output "spec" {
  value = terraform_data.spec.output
}
