Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
asg: make name_suffix optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ketzacoatl committed Jul 8, 2020
1 parent 71e59dd commit 4aa4bcf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions modules/asg/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
locals {
name_prefix_with_suffix = "${var.name_prefix}-${var.name_suffix}"
name_prefix_without_suffix = "${var.name_prefix}"

name_prefix = "${var.name_suffix != "" ? local.name_prefix_without_suffix : local.name_prefix_with_suffix}"

}
4 changes: 2 additions & 2 deletions modules/asg/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ resource "aws_autoscaling_group" "cluster" {
load_balancers = var.elb_names
max_size = var.max_nodes
min_size = var.min_nodes
name_prefix = "${var.name_prefix}-${var.name_suffix}"
name_prefix = local.name_prefix
placement_group = var.placement_group
termination_policies = var.termination_policies
protect_from_scale_in = var.protect_from_scale_in
Expand Down Expand Up @@ -71,7 +71,7 @@ resource "aws_autoscaling_group" "cluster" {
[
{
"key" = "Name"
"value" = "${var.name_prefix}-${var.name_suffix}"
"value" = local.name_prefix
"propagate_at_launch" = true
},
],
Expand Down

0 comments on commit 4aa4bcf

Please sign in to comment.