From 16ac3a1e7f3dbbb4a1443618d42b53b0e32183ce 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 0ddcaf1..42ee00e 100644 --- a/main.tf +++ b/main.tf @@ -69,7 +69,7 @@ module "access_logs" { } resource "aws_lb" "default" { - name = module.default_label.id + name = var.alb_name == "" ? module.default_label.id : var.alb_name tags = module.default_label.tags internal = var.internal load_balancer_type = "application" diff --git a/variables.tf b/variables.tf index 0c33823..8fb6a5d 100644 --- a/variables.tf +++ b/variables.tf @@ -55,6 +55,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