Skip to content

Commit

Permalink
added letsencrypt configuration for traefik
Browse files Browse the repository at this point in the history
  • Loading branch information
owngr committed Feb 2, 2022
1 parent d722c0e commit c8de6ed
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,11 @@ resource "local_file" "hetzner_csi_config" {

resource "local_file" "traefik_config" {
content = templatefile("${path.module}/templates/traefik_config.yaml.tpl", {
lb_disable_ipv6 = var.lb_disable_ipv6
lb_server_type = var.lb_server_type
location = var.location
lb_disable_ipv6 = var.lb_disable_ipv6
lb_server_type = var.lb_server_type
location = var.location
traefik_acme_tls = var.traefik_acme_tls
traefik_acme_email = var.traefik_acme_email
})
filename = "${path.module}/templates/rendered/traefik_config.yaml"
file_permission = "0644"
Expand Down
6 changes: 6 additions & 0 deletions templates/traefik_config.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ spec:
- "--entryPoints.websecure.proxyProtocol.trustedIPs=127.0.0.1/32,10.0.0.0/8"
- "--entryPoints.web.forwardedHeaders.trustedIPs=127.0.0.1/32,10.0.0.0/8"
- "--entryPoints.websecure.forwardedHeaders.trustedIPs=127.0.0.1/32,10.0.0.0/8"
%{ if traefik_acme_tls ~}
- "--certificatesresolvers.le.acme.httpchallenge=true"
- "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
- "--certificatesresolvers.le.acme.email=${traefik_acme_email}"
- "--certificatesresolvers.le.acme.storage=/data/acme.json"
%{ endif ~}
4 changes: 4 additions & 0 deletions terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ agents_num = 2
# that is probably the more "vanilla" option to keep these components always updated.
# hetzner_ccm_containers_latest = true
# hetzner_csi_containers_latest = true

# If you want to use letsencrypt with tls Challenge, the email address is used to send you certificates expiration notices
# traefik_acme_tls = true
# traefik_acme_email = "mail@example.com"
13 changes: 13 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,16 @@ variable "hetzner_csi_containers_latest" {
default = false
description = "Whether to kustomize the Hetzner CSI manifest with the latest or canary tags for containers"
}

variable "traefik_acme_tls" {
type = bool
default = false
description = "Wheter to include the TLS configuration with the Traefik configuration"
}

variable "traefik_acme_email" {
type = string
default = false
description = "Email used to recieved expiration notice for certificate"
}

0 comments on commit c8de6ed

Please sign in to comment.