Browse Source

Minor fixes in container zipmapping

1.0.0
Nemo 2 years ago
parent
commit
e8dcd00e87
5 changed files with 45 additions and 39 deletions
  1. +3
    -3
      echoserver.tf
  2. +4
    -0
      modules/container/locals.tf
  3. +34
    -31
      modules/container/main.tf
  4. +3
    -5
      modules/container/vars.tf
  5. +1
    -0
      requestbin.tf

docker/debug.tf → echoserver.tf View File

@ -1,11 +1,11 @@
module "echo-server" {
source = "../modules/container"
source = "modules/container"
name = "echo-server"
image = "jmalloc/echo-server:latest"
web {
expose = true
expose = "true"
port = 8080
domain = "debug.${var.domain},debug.in.${var.domain}"
host = "debug.${var.root-domain},debug.in.${var.root-domain}"
}
}

+ 4
- 0
modules/container/locals.tf View File

@ -9,6 +9,10 @@ locals {
"traefik.protocol" = "${lookup(var.web, "protocol", "http")}"
}
resource {
"memory" = "${lookup(var.resource, "memory", 64)}"
}
traefik_common_labels {
"traefik.enable" = "true"


+ 34
- 31
modules/container/main.tf View File

@ -18,8 +18,7 @@ resource "docker_container" "container" {
user = "${var.user}"
networks = ["${var.networks}"]
# memory = "${lookup(var.resource, "memory", "64")}"
memory = "${local.resource["memory"]}"
# Look at this monstrosity
# And then https://github.com/hashicorp/terraform/issues/12453#issuecomment-365569618
@ -28,71 +27,75 @@ resource "docker_container" "container" {
labels = "${merge(local.default_labels,
zipmap(
concat(
keys(local.traefik_common_labels),
split(",",
keys(local.default_labels),
split("~",
lookup(var.web, "expose", "false") == "false" ?
"" :
join(",", keys(local.traefik_common_labels))
join("~", keys(local.traefik_common_labels))
)
),concat(
values(local.traefik_common_labels),
split(",",
),
concat(
values(local.default_labels),
split("~",
lookup(var.web, "expose", "false") == "false" ?
"" :
join(",", values(local.traefik_common_labels))
join("~", values(local.traefik_common_labels))
)
)
),
zipmap(
concat(
keys(local.web),
split(",",
keys(local.default_labels),
split("~",
lookup(var.web, "expose", "false") == "false" ?
"" :
join(",", keys(local.web))
join("~", keys(local.web))
)
),concat(
values(local.web),
split(",",
),
concat(
values(local.default_labels),
split("~",
lookup(var.web, "expose", "false") == "false" ?
"" :
join(",", values(local.web))
join("~", values(local.web))
)
)
),
zipmap(
concat(
keys(local.traefik_common_labels),
split(",",
keys(local.default_labels),
split("~",
lookup(var.web, "expose", "false") == "false" ?
"" :
join(",", keys(local.traefik_common_labels))
join("~", keys(local.traefik_common_labels))
)
),concat(
values(local.traefik_common_labels),
split(",",
),
concat(
values(local.default_labels),
split("~",
lookup(var.web, "expose", "false") == "false" ?
"" :
join(",", values(local.traefik_common_labels))
join("~", values(local.traefik_common_labels))
)
)
),
zipmap(
concat(
keys(local.traefik_auth_labels),
split(",",
keys(local.default_labels),
split("~",
lookup(var.web, "auth", "false") == "false" ?
"" :
join(",", keys(local.traefik_auth_labels))
join("~", keys(local.traefik_auth_labels))
)
),concat(
values(local.traefik_auth_labels),
split(",",
),
concat(
values(local.default_labels),
split("~",
lookup(var.web, "auth", "false") == "false" ?
"" :
join(",", values(local.traefik_auth_labels))
join("~", values(local.traefik_auth_labels))
)
)
)


+ 3
- 5
modules/container/vars.tf View File

@ -68,8 +68,8 @@ variable "web" {
description = "Web Configuration"
default = {
expose = "false"
basicauth = "false"
expose = "false"
auth = "false"
}
}
@ -80,7 +80,5 @@ variable "auth_header" {
variable "resource" {
description = "Resource usage for the container"
default = {
memory = ""
}
default = {}
}

+ 1
- 0
requestbin.tf View File

@ -6,6 +6,7 @@ module "requestbin" {
// Default is port 80
web {
expose = true
port = "8000"
host = "requestbin.${var.root-domain}"
}


Loading…
Cancel
Save