@@ -21,9 +21,14 @@ locals {
2121 # To give us a short-hand refernce to the AZ
2222 az = data. aws_subnet . server-subnet . availability_zone
2323
24+ # with or without the suffix, eg, if suffix is empty, skip it and avoid the extra -
25+ name_prefix_with_suffix = " ${ var . name_prefix } -${ var . name_suffix } "
26+ name_prefix_without_suffix = " ${ var . name_prefix } "
27+ name_prefix = " ${ var . name_suffix != " " ? local . name_prefix_without_suffix : local . name_prefix_with_suffix } "
28+
2429 # The `name_prefix` we provide to the `iam-instance-profile` module
2530 # The persistent-ebs module appends the AZ to the data node name, other modules don't do that
26- name_prefix_with_az = " ${ var . name_prefix } - ${ var . name_suffix } -${ local . az } "
31+ name_prefix_with_az = " ${ local . name_prefix } -${ local . az } "
2732
2833 data_volume_default = {
2934 type = " gp2"
@@ -46,7 +51,7 @@ module "instance-profile" {
4651# Create a single EBS volume that can be used in a single/specific AZ, for the ASG
4752module "service-data" {
4853 source = " ../persistent-ebs"
49- name_prefix = " ${ var . name_prefix } - ${ var . name_suffix } "
54+ name_prefix = local . name_prefix_with_az
5055 region = var. region
5156 az = local. az
5257 volumes = local. data_volumes_default
@@ -72,8 +77,7 @@ module "server" {
7277 public_ip = var. public_ip
7378 # the prefix and suffix names are combined in
7479 # the `asg` module to create the full name
75- name_prefix = var. name_prefix
76- name_suffix = " ${ var . name_suffix } -${ local . az } "
80+ name_prefix = local. name_prefix_with_az
7781
7882 root_volume_type = var. root_volume_type
7983 root_volume_size = var. root_volume_size
0 commit comments