Initial socket-proxy
This commit is contained in:
parent
f965cc0a55
commit
c7dbc25229
4 changed files with 59 additions and 0 deletions
products/socket-proxy
34
products/socket-proxy/inputs.tf
Normal file
34
products/socket-proxy/inputs.tf
Normal 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
|
||||
})
|
||||
}
|
3
products/socket-proxy/outputs.tf
Normal file
3
products/socket-proxy/outputs.tf
Normal file
|
@ -0,0 +1,3 @@
|
|||
output "endpoint" {
|
||||
value = module.socat.endpoint
|
||||
}
|
10
products/socket-proxy/proxy.tf
Normal file
10
products/socket-proxy/proxy.tf
Normal 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
|
||||
}
|
12
products/socket-proxy/terraform.tf
Normal file
12
products/socket-proxy/terraform.tf
Normal file
|
@ -0,0 +1,12 @@
|
|||
terraform {
|
||||
required_version = "~> 1.6"
|
||||
|
||||
required_providers {
|
||||
docker = {
|
||||
source = "kreuzwerker/docker"
|
||||
version = "~>3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in a new issue