From ad867aebc3773d80cd30b197dc739efc1b9f0896 Mon Sep 17 00:00:00 2001 From: hskiba Date: Mon, 23 Jan 2023 15:11:43 +0800 Subject: [PATCH] Add the ability to specify default and additional tags for instances (#9) --- instances.tf | 5 +++-- variables.tf | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/instances.tf b/instances.tf index af5c041..ec0fb72 100644 --- a/instances.tf +++ b/instances.tf @@ -3,8 +3,8 @@ locals { } module "spot_requests" { - source = "frgrisk/ec2-spot/aws" - version = "~>0.3.0" + source = "frgrisk/ec2-spot/aws" + version = "~>0.3.2" for_each = var.spot_requests @@ -25,6 +25,7 @@ module "spot_requests" { root_volume_size = coalesce(each.value.root_volume_size, 30) additional_volumes = lookup(var.additional_volumes, each.key, {}) encrypt_volumes = var.encrypt_volumes + additional_tags = merge(var.default_tags, each.value.additional_tags) user_data_replace_on_change = coalesce(each.value.user_data_replace_on_change, true) } diff --git a/variables.tf b/variables.tf index b3c8505..5f63c44 100644 --- a/variables.tf +++ b/variables.tf @@ -12,9 +12,16 @@ variable "spot_requests" { user_data = optional(string) user_data_replace_on_change = optional(bool) placement_group = optional(string) + additional_tags = optional(map(string)) })) } +variable "default_tags" { + description = "Default tags to apply to all resources" + type = map(string) + default = {} +} + variable "tag_environment" { description = "The name of the environment to use in resource tagging" type = string