Initial socket-proxy

This commit is contained in:
Greyscale 2025-01-17 11:51:10 +01:00
parent f965cc0a55
commit c7dbc25229
Signed by: grey
GPG key ID: DDB392AE64B32D89
4 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,34 @@
variable "stack_name" {
type = string
description = "The name of the stack to deploy the service to."
}
variable "service_name" {
type = string
description = "The name of the service to deploy. Will be appended with the stack name."
}
variable "traefik" {
default = null
type = object({
domain = string
port = optional(number)
non-ssl = optional(bool, true)
ssl = optional(bool, false)
rule = optional(string)
middlewares = optional(list(string), [])
network = optional(object({ name = string, id = string }))
basic-auth-users = optional(list(string), [])
headers = optional(map(string), {})
})
description = "Whether to enable traefik for the service."
}
variable "placement_constraints" {
default = []
type = list(string)
description = "Docker Swarm placement constraints"
}
variable "target" {
type = object({
host = string
port = number
})
}

View file

@ -0,0 +1,3 @@
output "endpoint" {
value = module.socat.endpoint
}

View file

@ -0,0 +1,10 @@
module "socat" {
source = "github.com/matthewbaggett/terraform_modules//docker/service"
stack_name = var.stack_name
service_name = var.service_name
image = "alpine/socat:latest"
command = ["socat", "tcp-listen:${var.target.port},fork,reuseaddr", "tcp-connect:${var.target.host}:${var.target.port}"]
traefik = merge({ port = var.target.port }, var.traefik)
converge_enable = false
placement_constraints = var.placement_constraints
}

View file

@ -0,0 +1,12 @@
terraform {
required_version = "~> 1.6"
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "~>3.0"
}
}
}