Skip to content

Commit

Permalink
Add abbility to set SSL certificate via ARN
Browse files Browse the repository at this point in the history
  • Loading branch information
ToROxI committed Feb 19, 2019
1 parent 566a800 commit d33849b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ resource "aws_s3_bucket_policy" "alb-logs" {
}

data "aws_acm_certificate" "this" {
count = "${ lower(var.ssl_certificate_arn) == "none" ? 1 : 0 }"
domain = "${var.acm_cert_domain}"
statuses = ["ISSUED", "PENDING_VALIDATION"]
most_recent = "${var.most_recent_certificate}"
Expand All @@ -90,7 +91,7 @@ module "alb" {
vpc_id = "${var.vpc_id}"

/////// Configure listeners and target groups ///////
https_listeners = "${list(map("certificate_arn", "${data.aws_acm_certificate.this.arn}", "port", "${var.default_https_tcp_listeners_port}"))}"
https_listeners = "${list(map("certificate_arn", "${element(concat(data.aws_acm_certificate.this.*.arn, list(var.ssl_certificate_arn)), 0)}", "port", "${var.default_https_tcp_listeners_port}"))}"
https_listeners_count = "${var.default_https_tcp_listeners_count}"

http_tcp_listeners = "${list(map("port", "${var.default_http_tcp_listeners_port}", "protocol", "HTTP"))}"
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ variable "root_domain" {
description = "Root domain in which custom DNS record for ALB would be created"
}

variable "ssl_certificate_arn" {
description = "ARN of SSL certificate to use for ALB"
default = "none"
}

variable "tags" {
type = "map"
description = "Additional tags for resources"
Expand Down

0 comments on commit d33849b

Please sign in to comment.