Opinionated.tf/docker-service/inputs.tf

118 lines
3.7 KiB
Terraform
Raw Normal View History

2024-07-29 19:28:08 +00:00
variable "image" {
type = string
}
variable "command" {
type = list(string)
default = null
}
2024-07-30 02:08:50 +00:00
variable "one_shot" {
type = bool
default = false
description = "Whether to run the service as a one-shot task."
}
2024-07-29 19:28:08 +00:00
variable "stack_name" {
2024-07-31 12:26:17 +00:00
type = string
description = "The name of the stack to deploy the service to."
2024-07-29 19:28:08 +00:00
}
variable "service_name" {
2024-07-31 12:26:17 +00:00
type = string
description = "The name of the service to deploy. Will be appended with the stack name."
2024-07-29 19:28:08 +00:00
}
variable "environment_variables" {
2024-07-31 12:26:17 +00:00
type = map(string)
default = {}
description = "A map of environment variables to set in the container."
2024-07-29 19:28:08 +00:00
}
variable "networks" {
2024-07-31 12:26:17 +00:00
type = list(string)
default = []
description = "A list of network names to attach the service to."
2024-07-29 19:28:08 +00:00
}
variable "healthcheck" {
2024-07-31 12:26:17 +00:00
type = list(string)
default = null
description = "Healthcheck command to run, in the docker style."
2024-07-29 19:28:08 +00:00
}
variable "volumes" {
2024-07-31 12:26:17 +00:00
type = map(string)
default = {}
description = "A map of volume names to create and mount. The key is the volume name, and the value is the mount point."
}
variable "mounts" {
type = map(string)
default = {}
description = "A map of host paths to container paths to mount. The key is the host path, and the value is the container path."
}
variable "configs" {
type = map(object({
name_prefix = list(string),
contents = string,
path = string
}))
default = {}
description = "A map of config names to create and mount. The key is the config name, and the value is the config contents."
2024-07-29 19:28:08 +00:00
}
variable "ports" {
2024-07-31 13:16:04 +00:00
type = list(object({
host = number
container = number
2024-07-31 14:13:06 +00:00
protocol = optional(string, "tcp")
2024-07-31 13:16:04 +00:00
}))
default = []
2024-07-29 19:28:08 +00:00
description = "A map of port mappings to expose on the host. The key is the host port, and the value is the container port."
2024-07-31 14:13:06 +00:00
validation {
error_message = "Host Ports must be between 1024 and 65535."
condition = alltrue([for port in var.ports : port.host >= 1024 && port.host <= 65535])
}
validation {
error_message = "Container Ports must be between 1 and 65535."
condition = alltrue([for port in var.ports : port.container >= 1 && port.container <= 65535])
}
validation {
error_message = "protocol must be either 'tcp' or 'udp'."
condition = alltrue([for port in var.ports : port.protocol == "tcp" || port.protocol == "udp"])
}
2024-07-29 19:28:08 +00:00
}
variable "dns_nameservers" {
type = list(string)
default = null
description = "A list of DNS nameservers to use for the service."
}
2024-07-29 19:28:08 +00:00
# Scaling and deployment variables
variable "parallelism" {
default = 1
type = number
description = "The number of instances to run."
}
variable "update_waves" {
default = 3
type = number
description = "When updating a multi-instance service, the number of waves of updates to run."
}
variable "start_first" {
default = true
type = bool
description = "When updating a multi-instance service, whether to start or stop instances first. Start-first allows for a clean handoff, but not every instance is capable of this."
}
variable "global" {
default = false
type = bool
description = "Whether to run the service globally (or replicated if false)."
}
variable "placement_constraints" {
default = []
type = list(string)
description = "Docker Swarm placement constraints"
}
variable "processor_architecture" {
2024-07-31 12:26:17 +00:00
default = "amd64"
type = string
description = "The processor architecture to use for the service."
2024-07-29 19:28:08 +00:00
}
variable "operating_system" {
2024-07-31 12:26:17 +00:00
default = "linux"
type = string
description = "The operating system to use for the service. Almost always 'linux'."
2024-07-29 19:28:08 +00:00
}