New optional variable for a prefix to place in front of instance names in case someone wants to run multiple DetectionLab instances within the same AWS account so it's easier to tell instances apart which would otherwise all have the same names

This commit is contained in:
Chad Roberts
2020-06-25 13:16:27 -07:00
parent 9ed04160c0
commit d337c57b25
3 changed files with 10 additions and 5 deletions

View File

@@ -159,7 +159,7 @@ resource "aws_instance" "logger" {
ami = coalesce(var.logger_ami, data.aws_ami.logger_ami.image_id)
tags = {
Name = "logger"
Name = "${var.tag_prefix}logger"
}
subnet_id = aws_subnet.default.id
@@ -223,7 +223,7 @@ resource "aws_instance" "dc" {
ami = coalesce(var.dc_ami, data.aws_ami.dc_ami.image_id)
tags = {
Name = "dc.windomain.local"
Name = "${var.tag_prefix}dc.windomain.local"
}
subnet_id = aws_subnet.default.id
@@ -258,7 +258,7 @@ resource "aws_instance" "wef" {
ami = coalesce(var.wef_ami, data.aws_ami.wef_ami.image_id)
tags = {
Name = "wef.windomain.local"
Name = "${var.tag_prefix}wef.windomain.local"
}
subnet_id = aws_subnet.default.id
@@ -293,7 +293,7 @@ resource "aws_instance" "win10" {
ami = coalesce(var.win10_ami, data.aws_ami.win10_ami.image_id)
tags = {
Name = "win10.windomain.local"
Name = "${var.tag_prefix}win10.windomain.local"
}
subnet_id = aws_subnet.default.id
@@ -304,4 +304,3 @@ resource "aws_instance" "win10" {
delete_on_termination = true
}
}

View File

@@ -6,3 +6,4 @@ public_key_path = "/home/user/.ssh/id_logger.pub"
private_key_path = "/home/user/.ssh/id_logger"
ip_whitelist = ["1.2.3.4/32"]
availability_zone = "us-west-1b"
// tag_prefix = "some_prefix_"

View File

@@ -6,6 +6,11 @@ variable "profile" {
default = "terraform"
}
variable "tag_prefix" {
description = "Optional string to prefix at the front of instance names in case you need to run multiple DetectionLab environments in the same AWS account"
default = ""
}
variable "availability_zone" {
description = "https://www.terraform.io/docs/providers/aws/d/availability_zone.html"
default = ""