Skip to content

Commit

Permalink
Certificate on-demand in istio-gateway and new input params gateway h…
Browse files Browse the repository at this point in the history
…osts and credentialName (#255)
  • Loading branch information
bcarranza authored Feb 18, 2022
1 parent bc26507 commit ae7e021
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ spec:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
host: ${gateway_hosts}
- port:
number: 443
name: https
protocol: HTTPS
tls:
mode: SIMPLE
credentialName: domain-wildcard # This should match the Certificate secretName
credentialName: ${gateway_credentialName} # This should match the Certificate secretName
hosts:
- "*" # This should match a DNS name in the Certificate
6 changes: 5 additions & 1 deletion terraform-modules/aws/istio-networking/main-gateway/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ data "template_file" "gateway" {

vars = {
namespace = var.namespace
gateway_hosts = "${jsonencode(var.gateway_hosts)}"
gateway_credentialName = var.gateway_credentialName
}
}

Expand All @@ -24,6 +26,7 @@ resource "kubectl_manifest" "gateway" {

# file templating
data "template_file" "certificate" {
count = var.enable_certificate ? 1 : 0
template = file("${path.module}/certificate.tpl.yaml")

vars = {
Expand All @@ -38,5 +41,6 @@ data "template_file" "certificate" {
}

resource "kubectl_manifest" "certificate" {
yaml_body = data.template_file.certificate.rendered
count = var.enable_certificate ? 1 : 0
yaml_body = data.template_file.certificate[0].rendered
}
20 changes: 19 additions & 1 deletion terraform-modules/aws/istio-networking/main-gateway/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ variable "cert_dns_name" {
type = string
description = "The dns name for the certificate"
}


variable "enable_certificate" {
type = bool
description = "If set to true, it will create the certificate resource on-demand"
default = true
}

variable "issue_ref_name" {
default = "letsencrypt-prod-dns01"
}
Expand All @@ -39,4 +45,16 @@ variable "issue_ref_kind" {

variable "issue_ref_group" {
default = "cert-manager.io"
}

variable "gateway_hosts" {
type = list(string)
description = "the list of hosts available for the gateway"
default = ["*"]
}

variable "gateway_credentialName" {
type = string
description = "This is the gateway matches the secretName field in the certificate"
default = "domain-wildcard"
}

0 comments on commit ae7e021

Please sign in to comment.