Skip to content

Commit

Permalink
add ssl cert
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbroks committed Aug 29, 2024
1 parent 71c1b77 commit 8c31325
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
19 changes: 19 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ module "gke" {
depends_on = [module.networking, module.service_accounts]
}

resource "google_compute_global_address" "this" {
name = "${var.namespace}-address"
}

resource "google_compute_managed_ssl_certificate" "this" {
name = "${var.namespace}-cert"

managed {
domains = var.domains
}

lifecycle {
create_before_destroy = true
}
}

module "helm_release" {
source = "./modules/helm_release"

Expand All @@ -79,5 +95,8 @@ module "helm_release" {

service_account_email = module.service_accounts.service_account_email

global_static_ip_name = google_compute_global_address.this.name
pre_shared_cert = google_compute_managed_ssl_certificate.this.name

depends_on = [module.gke]
}
13 changes: 13 additions & 0 deletions modules/helm_release/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ resource "helm_release" "this" {
})
}

set {
name = "ingress"
value = yamlencode({
"enabled" = true
"annotations" = {
"kubernetes.io/ingress.class" = "gce"
"kubernetes.io/ingress.global-static-ip-name" = var.global_static_ip_name
"ingress.gcp.kubernetes.io/pre-shared-cert" = var.pre_shared_cert
"kubernetes.io/ingress.allow-http" = "false"
}
})
}

set {
name = "webservice"
value = yamlencode({
Expand Down
8 changes: 8 additions & 0 deletions modules/helm_release/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,11 @@ variable "service_account_email" {
type = string
description = "The service account email."
}

variable "global_static_ip_name" {
type = string
}

variable "pre_shared_cert" {
type = string
}
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ variable "deletion_protection" {
default = true
}

variable "domains" {
description = "The domains to use for the SSL certificate."
type = list(string)

}

0 comments on commit 8c31325

Please sign in to comment.