2025-01-21 19:12:09 +00:00
variable " enable " {
default = true
type = bool
description = " Whether to enable the service or to merely provision the service. "
}
2024-07-29 19:28:08 +00:00
variable " image " {
2024-12-09 23:47:04 +00:00
type = string
description = " The image to deploy/build/tag. "
}
variable " build " {
type = object ( {
context = string
dockerfile = optional ( string , " Dockerfile " )
2024-12-12 21:28:13 +00:00
target = optional ( string , null )
args = optional ( map ( string ) , { } )
tags = optional ( list ( string ) , [ ] )
2024-12-09 23:47:04 +00:00
} )
default = null
description = " The build configuration for the image. "
2024-07-29 19:28:08 +00:00
}
2024-11-24 13:00:40 +00:00
variable " mirror " {
type = string
default = null
description = " Whether to mirror the image to the local registry. Value is the mirror location. "
}
2024-07-29 19:28:08 +00:00
variable " command " {
type = list ( string )
default = null
}
2024-11-23 04:06:26 +00:00
variable " restart_policy " {
type = string
default = " any "
description = " The restart policy for the service. "
validation {
error_message = " Restart policy must be either 'any', 'on-failure', or 'none'. "
condition = var . restart_policy == " any " | | var . restart_policy == " on-failure " | | var . restart_policy == " none "
}
}
2024-11-26 09:50:53 +00:00
variable " restart_delay " {
type = string
default = " 0s "
description = " The delay before restarting the service. "
}
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-11-26 13:42:54 +00:00
type = list ( object ( {
name = string
id = string
} ) )
2024-07-31 12:26:17 +00:00
default = [ ]
2025-01-06 09:45:37 +00:00
description = " A list of network objects 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
}
2024-12-22 06:42:50 +00:00
variable " healthcheck_interval " {
type = string
default = " 10s "
description = " The interval to run the healthcheck. "
}
variable " healthcheck_timeout " {
type = string
default = " 3s "
description = " The timeout for the healthcheck. "
}
variable " healthcheck_retries " {
type = number
default = 0
description = " The number of retries for the healthcheck. "
}
variable " healthcheck_start_period " {
type = string
default = " 0s "
description = " The start period for the healthcheck. "
}
2024-07-29 19:28:08 +00:00
variable " volumes " {
2024-07-31 12:26:17 +00:00
type = map ( string )
default = { }
2024-11-26 10:50:09 +00:00
description = " A map of internally created volume names to create and mount. The key is the volume name, and the value is the mount point. "
2024-07-31 12:26:17 +00:00
}
2024-11-23 04:06:26 +00:00
variable " remote_volumes " {
2024-11-26 09:50:53 +00:00
type = map ( object ( {
id = string
driver = string
} ) )
2024-11-23 04:06:26 +00:00
default = { }
2024-11-26 10:50:09 +00:00
description = " A remote volume is a volume created explicitly and not implicitly by this Service. This is a map of remote volumes to mount into the container. The key is the source, and the value is the target. "
2024-11-23 04:06:26 +00:00
}
2024-07-31 12:26:17 +00:00
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. "
}
2025-02-14 20:31:35 +00:00
variable " secrets " {
type = map ( string )
default = { }
description = " A map of secret files to create. Key being the path to the file, and the value being the content. The secret will be created using the truncated file name and a timestamp. "
}
2024-07-31 12:26:17 +00:00
variable " configs " {
2024-11-23 04:06:26 +00:00
type = map ( string )
2024-07-31 12:26:17 +00:00
default = { }
2024-11-23 04:06:26 +00:00
description = " A map of config files to create. Key being the path to the file, and the value being the content. The config will be created using the truncated file name and a timestamp. "
2024-07-29 19:28:08 +00:00
}
2025-01-06 09:45:37 +00:00
variable " remote_configs " {
type = map ( object ( {
id = string
name = string
} ) )
default = { }
description = " A remote config is a config created explicitly and not implicitly by this Service. This is a map of remote configs to mount into the container. The key is the source, and the value is the target. "
}
2024-07-29 19:28:08 +00:00
variable " ports " {
2024-07-31 13:16:04 +00:00
type = list ( object ( {
2025-03-03 14:51:18 +00:00
host = optional ( number , null )
container = number
protocol = optional ( string , " tcp " )
publish_mode = optional ( string , " ingress " )
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 {
2024-12-04 13:30:45 +00:00
error_message = " Host Ports must be between 1 and 65535. Or null. "
# This condition is structured wierd because terraform doesn't have
# short-circuiting and a variable that is null cannot also be read
# for the port number validation.
condition = alltrue ( [ for port in var . ports : port . host == null ? true : ( port . host > = 1 && port . host < = 65535 ) ] )
2024-07-31 14:13:06 +00:00
}
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 {
2024-12-04 13:30:45 +00:00
error_message = " Protocol must be either 'tcp' or 'udp'. "
2024-07-31 14:13:06 +00:00
condition = alltrue ( [ for port in var . ports : port . protocol == " tcp " | | port . protocol == " udp " ] )
}
2024-07-29 19:28:08 +00:00
}
2024-08-01 17:29:56 +00:00
variable " dns_nameservers " {
type = list ( string )
2024-08-03 22:07:12 +00:00
default = null
2024-08-01 17:29:56 +00:00
description = " A list of DNS nameservers to use for the service. "
}
2024-08-29 11:49:03 +00:00
variable " labels " {
type = map ( string )
default = { }
description = " A map of labels to apply to 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. "
}
2024-11-26 09:50:53 +00:00
variable " parallelism_per_node " {
default = 0
type = number
description = " The maximum number of instances to run per node. 0 means no limit. "
}
2024-07-29 19:28:08 +00:00
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
}
2024-11-23 04:06:26 +00:00
variable " converge_enable " {
default = true
type = bool
description = " Whether to enable the converge configuration. "
}
2024-09-23 21:45:34 +00:00
variable " converge_timeout " {
default = " 2m "
type = string
description = " The timeout for the service to converge. "
2024-11-26 09:50:53 +00:00
}
variable " limit_cpu " {
default = null
type = number
description = " The CPU limit for the service. "
}
variable " limit_ram_mb " {
default = null
type = number
description = " The RAM limit for the service, measured in megabytes. "
}
variable " reserved_cpu " {
default = null
type = number
description = " The CPU reservation for the service. "
}
variable " reserved_ram_mb " {
default = null
type = number
description = " The RAM reservation for the service, measured in megabytes. "
2025-02-14 20:33:15 +00:00
}
variable " shm_size_mb " {
default = null
type = number
description = " The size of the shared memory segment in megabytes. "
2024-09-23 21:45:34 +00:00
}