Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data "aws_ami_ids" "ami" {
}

locals {
cluster_name = "rabbitmq-${var.name}"
cluster_name = "${var.name}-rabbitmq"
}

resource "random_string" "admin_password" {
Expand Down Expand Up @@ -93,7 +93,7 @@ resource "aws_iam_instance_profile" "profile" {
}

resource "aws_security_group" "rabbitmq_elb" {
name = "rabbitmq_elb-${var.name}"
name = "${var.name}-rabbitmq_elb"
vpc_id = var.vpc_id
description = "Security Group for the rabbitmq elb"

Expand All @@ -104,9 +104,10 @@ resource "aws_security_group" "rabbitmq_elb" {
cidr_blocks = ["0.0.0.0/0"]
}

tags = {
Name = "rabbitmq ${var.name} ELB"
}
tags = merge(
{Name = "${var.name} rabbitmq ELB"},
var.tags
)
}

resource "aws_security_group" "rabbitmq_nodes" {
Expand Down Expand Up @@ -145,9 +146,10 @@ resource "aws_security_group" "rabbitmq_nodes" {
]
}

tags = {
Name = "rabbitmq ${var.name} nodes"
}
tags = merge(
{Name = "${var.name} rabbitmq nodes"},
var.tags
)
}

resource "aws_launch_configuration" "rabbitmq" {
Expand Down Expand Up @@ -188,6 +190,16 @@ resource "aws_autoscaling_group" "rabbitmq" {
value = local.cluster_name
propagate_at_launch = true
}

dynamic "tag" {
for_each = var.tags

content {
key = tag.key
value = tag.value
propagate_at_launch = true
}
}
}

resource "aws_elb" "elb" {
Expand Down Expand Up @@ -220,7 +232,8 @@ resource "aws_elb" "elb" {
internal = true
security_groups = concat([aws_security_group.rabbitmq_elb.id], var.elb_additional_security_group_ids)

tags = {
Name = local.cluster_name
}
tags = merge(
{Name = local.cluster_name},
var.tags
)
}
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ variable "instance_volume_iops" {
default = "0"
}

variable "tags" {
description = "A map of tags to add to all resources"
type = map(string)
default = {}
}