Skip to content

Commit 08eb577

Browse files
author
Ryan Craig
authored
feat: Add "num_suffix_format" variable for instance naming (#147)
1 parent 10a3b54 commit 08eb577

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ No requirements.
124124
| monitoring | If true, the launched EC2 instance will have detailed monitoring enabled | `bool` | `false` | no |
125125
| name | Name to be used on all resources as prefix | `string` | n/a | yes |
126126
| network\_interface | Customize network interfaces to be attached at instance boot time | `list(map(string))` | `[]` | no |
127+
| num\_suffix\_format | Numerical suffix format used as the volume and EC2 instance name suffix | `string` | `"-%d"` | no |
127128
| placement\_group | The Placement Group to start the instance in | `string` | `""` | no |
128129
| private\_ip | Private IP address to associate with the instance in a VPC | `string` | `null` | no |
129130
| private\_ips | A list of private IP address to associate with the instance in a VPC. Should match the number of instances. | `list(string)` | `[]` | no |

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ resource "aws_instance" "this" {
7878

7979
tags = merge(
8080
{
81-
"Name" = var.instance_count > 1 || var.use_num_suffix ? format("%s-%d", var.name, count.index + 1) : var.name
81+
"Name" = var.instance_count > 1 || var.use_num_suffix ? format("%s${var.num_suffix_format}", var.name, count.index + 1) : var.name
8282
},
8383
var.tags,
8484
)
8585

8686
volume_tags = merge(
8787
{
88-
"Name" = var.instance_count > 1 || var.use_num_suffix ? format("%s-%d", var.name, count.index + 1) : var.name
88+
"Name" = var.instance_count > 1 || var.use_num_suffix ? format("%s${var.num_suffix_format}", var.name, count.index + 1) : var.name
8989
},
9090
var.volume_tags,
9191
)

variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,10 @@ variable "use_num_suffix" {
187187
default = false
188188
}
189189

190+
variable "num_suffix_format" {
191+
description = "Numerical suffix format used as the volume and EC2 instance name suffix"
192+
type = string
193+
default = "-%d"
194+
}
195+
196+

0 commit comments

Comments
 (0)