From 38695749ae2cb51b41798904e842c5b78e74a17f Mon Sep 17 00:00:00 2001 From: Michael Manganiello Date: Thu, 10 Sep 2020 19:25:59 -0300 Subject: [PATCH] Add alb_name variable to specify load balancer name According to AWS docs [0], the Load Balancer name is limited to 32 characters. Similar to #27, this diff adds an `alb_name` variable to avoid using the default label id, if set. [0] https://docs.aws.amazon.com/elasticloadbalancing/2012-06-01/APIReference/API_CreateLoadBalancer.html --- main.tf | 2 +- variables.tf | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/main.tf b/main.tf index ce12e84..5b65406 100644 --- a/main.tf +++ b/main.tf @@ -61,7 +61,7 @@ module "access_logs" { resource "aws_lb" "default" { count = module.this.enabled ? 1 : 0 - name = module.this.id + name = var.alb_name == "" ? module.this.id : var.alb_name tags = module.this.tags internal = var.internal load_balancer_type = "application" diff --git a/variables.tf b/variables.tf index 5d19aa8..cfd42ae 100644 --- a/variables.tf +++ b/variables.tf @@ -14,6 +14,12 @@ variable "security_group_ids" { description = "A list of additional security group IDs to allow access to ALB" } +variable "alb_name" { + type = string + default = "" + description = "The name for the load balancer, uses a module label name if left empty" +} + variable "internal" { type = bool default = false