Skip to content

Commit

Permalink
Add alb_name variable to specify load balancer name
Browse files Browse the repository at this point in the history
According to AWS docs [0], the Load Balancer name is limited to 32
characters. Similar to cloudposse#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
  • Loading branch information
adamantike committed Jan 27, 2021
1 parent 5ddd35e commit 6b6ab82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b6ab82

Please sign in to comment.