Skip to content

Commit f7f1960

Browse files
author
Steven Nemetz
committed
Attempting to create ASG tags list
1 parent b2ed6b1 commit f7f1960

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

main.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
# Create tags_asg list from tags map. If possible
77
# New input tags_asg -> tags_asg with standard tags added
88

9+
module "autoscaling_group" {
10+
source = "devops-workflow/boolean/local"
11+
version = "0.1.0"
12+
value = "${var.autoscaling_group}"
13+
}
914
module "namespace-env" {
1015
source = "devops-workflow/boolean/local"
1116
version = "0.1.0"
@@ -75,6 +80,21 @@ locals {
7580
*/
7681
}
7782

83+
/*
84+
Could use null_resource to create? Would need enable/disable so only done when needed
85+
Can only assign strings (NOT maps or lists)
86+
*/
87+
/*
88+
resource "null_resource" "asg_tags" {
89+
count = "${var.autoscaling_group ? length(keys(local.tags)) : 0}"
90+
triggers = {
91+
asg_tag = "${map("key", element(keys(local.tags),count.index), "value", element(values(local.tags),count.index), "propagate_at_launch", true)}"
92+
}
93+
lifecycle {
94+
create_before_destroy = true
95+
}
96+
}
97+
*/
7898
/* locals doesn't currently support count
7999
locals {
80100
count = "${length(keys(local.tags))}"

test/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module "labels" {
88
#attributes = ["role", "policy", "use", ""]
99
attributes = ["8080"]
1010
tags = "${map("Key", "Value")}"
11+
autoscaling_group = true
1112
}
1213

1314
/*

variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ variable "attributes" {
33
type = "list"
44
default = []
55
}
6+
variable "autoscaling_group" {
7+
description = "If true, generate ASG tags map resource"
8+
default = false
9+
}
610
variable "delimiter" {
711
description = "Delimiter to be used between `name`, `namespaces`, `attributes`, etc."
812
default = "-"

0 commit comments

Comments
 (0)