Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #12 from sclausson/cluster_tag_value
Browse files Browse the repository at this point in the history
Use interpolated tags syntax to add extra tags to cluster nodes
  • Loading branch information
brikis98 authored Oct 9, 2017
2 parents 1b66be4 + 8258fb1 commit c149406
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
17 changes: 17 additions & 0 deletions modules/vault-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ module "vault_cluster" {
#!/bin/bash
/opt/vault/bin/run-vault --s3-bucket ${var.vault_s3_bucket} --s3-bucket-region ${var.aws_region} --tls-cert-file /opt/vault/tls/vault.crt.pem --tls-key-file /opt/vault/tls/vault.key.pem
EOF
# Add tag to each node in the cluster with value set to var.cluster_name
cluster_tag_key = "Name"
# Optionally add extra tags to each node in the cluster
cluster_extra_tags = [
{
key = "Environment"
value = "Dev"
propagate_at_launch = true
},
{
key = "Department"
value = "Ops"
propagate_at_launch = true
}
]
# ... See vars.tf for the other parameters you must define for the vault-cluster module
}
Expand Down
11 changes: 6 additions & 5 deletions modules/vault-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ resource "aws_autoscaling_group" "autoscaling_group" {
health_check_grace_period = "${var.health_check_grace_period}"
wait_for_capacity_timeout = "${var.wait_for_capacity_timeout}"

tag {
key = "${var.cluster_tag_key}"
value = "${var.cluster_name}"
propagate_at_launch = true
}
tags = ["${concat(
list(
map("key", var.cluster_tag_key, "value", var.cluster_name, "propagate_at_launch", true)
),
var.cluster_extra_tags)
}"]
}

# ---------------------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions modules/vault-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ variable "cluster_tag_key" {
default = "Name"
}

variable "cluster_extra_tags" {
description = "A list of additional tags to add to each Instance in the ASG. Each element in the list must be a map with the keys key, value, and propagate_at_launch"
type = "list"
#example:
# default = [
# {
# key = "Environment"
# value = "Dev"
# propagate_at_launch = true
# }
# ]
default = []
}

variable "termination_policies" {
description = "A list of policies to decide how the instances in the auto scale group should be terminated. The allowed values are OldestInstance, NewestInstance, OldestLaunchConfiguration, ClosestToNextInstanceHour, Default."
default = "Default"
Expand Down

0 comments on commit c149406

Please sign in to comment.