Skip to content
This repository has been archived by the owner on Jan 4, 2024. It is now read-only.

add use_existing_certificate option #1

Merged
merged 1 commit into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ resource "google_compute_target_https_proxy" "default" {
count = "${var.ssl ? 1 : 0}"
name = "${var.name}-https-proxy"
url_map = "${element(compact(concat(list(var.url_map), google_compute_url_map.default.*.self_link)), 0)}"
ssl_certificates = ["${google_compute_ssl_certificate.default.self_link}"]
ssl_certificates = [ "${element(compact(concat(list(var.certificate_link), google_compute_ssl_certificate.default.*.self_link)), 0)}" ]
}

resource "google_compute_ssl_certificate" "default" {
project = "${var.project}"
count = "${var.ssl ? 1 : 0}"
count = "${(var.ssl && !var.use_existing_certificate) ? 1 : 0}"
name = "${var.name}-certificate"
private_key = "${var.private_key}"
certificate = "${var.certificate}"
Expand Down
16 changes: 13 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,26 @@ variable url_map {
}

variable ssl {
description = "Set to `true` to enable SSL support, requires variables `private_key` and `certificate`."
description = "Set to `true` to enable SSL support, requires variables `private_key` and `certificate`, or `use_existing_certificate` and `certificate_link`."
default = false
}

variable private_key {
description = "Content of the private SSL key. Required if ssl is `true`."
description = "Content of the private SSL key. Required if `ssl` is `true` and `use_existing_certificate` is `false`."
default = ""
}

variable certificate {
description = "Content of the SSL certificate. Required if ssl is `true`."
description = "Content of the SSL certificate. Required if `ssl` is `true` and `use_existing_certificate` is `false`."
default = ""
}

variable use_existing_certificate {
description = "Use a certificate that has already been created. Requires `certificate_link`."
default = true
}

variable certificate_link {
description = "self_link for an existing certificate to use in this load balancer."
default = ""
}