Skip to content

Commit

Permalink
ECS instasnce tags
Browse files Browse the repository at this point in the history
  • Loading branch information
qbart committed Jul 15, 2022
1 parent 85b6cb3 commit 99e8f94
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion modules/ecs-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ resource "aws_autoscaling_group" "this" {
propagate_at_launch = true
}

tag {
key = "ssm.group"
value = var.ssm_tag_value
propagate_at_launch = true
}

dynamic "tag" {
for_each = var.tags
content {
Expand Down Expand Up @@ -129,7 +135,11 @@ data "cloudinit_config" "this" {
content = templatefile("${path.module}/scripts/user_data.sh.tpl",
{
ecs_cluster = aws_ecs_cluster.this.name,
ecs_loglevel = var.ecs_loglevel
ecs_loglevel = var.ecs_loglevel,
ecs_tags = jsonencode(merge(var.tags, {
"Name" = random_id.prefix.hex,
"ssm.group" = var.ssm_tag_value,
}))
}
)
}
Expand Down
1 change: 1 addition & 0 deletions modules/ecs-cluster/scripts/user_data.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ echo "Configure ECS cluster"
cat <<'CONFIG' >> /etc/ecs/ecs.config
ECS_CLUSTER=${ecs_cluster}
ECS_LOGLEVEL=${ecs_loglevel}
ECS_CONTAINER_INSTANCE_TAGS=${ecs_tags}
CONFIG

0 comments on commit 99e8f94

Please sign in to comment.