Skip to content

Commit 3d627e2

Browse files
committed
make module, split SGs, add outputs
1 parent 2d83ebc commit 3d627e2

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

main.tf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
provider "aws" {
2-
region = "${var.region}"
3-
access_key = "${var.access_key}"
4-
secret_key = "${var.secret_key}"
5-
}
6-
71
data "aws_vpc" "vpc" {
82
id = "${var.vpc_id}"
93
}
@@ -83,14 +77,14 @@ resource "aws_security_group" "rabbitmq_elb" {
8377
protocol = "tcp"
8478
from_port = 5672
8579
to_port = 5672
86-
security_groups = ["${var.security_group_ids}"]
80+
security_groups = ["${var.elb_security_group_ids}"]
8781
}
8882

8983
ingress {
9084
protocol = "tcp"
9185
from_port = 80
9286
to_port = 80
93-
security_groups = ["${var.security_group_ids}"]
87+
security_groups = ["${var.elb_security_group_ids}"]
9488
}
9589

9690
egress {
@@ -135,7 +129,7 @@ resource "aws_security_group" "rabbitmq_nodes" {
135129
protocol = "tcp"
136130
from_port = 22
137131
to_port = 22
138-
security_groups = ["${var.security_group_ids}"]
132+
security_groups = ["${var.ssh_security_group_ids}"]
139133
}
140134

141135
egress {
@@ -172,7 +166,13 @@ resource "aws_autoscaling_group" "rabbitmq" {
172166
force_delete = true
173167
launch_configuration = "${aws_launch_configuration.rabbitmq.name}"
174168
load_balancers = ["${aws_elb.elb.name}"]
175-
vpc_zone_identifier = "${var.subnet_ids}"
169+
vpc_zone_identifier = ["${var.subnet_ids}"]
170+
171+
tag {
172+
key = "Name"
173+
value = "rabbitmq"
174+
propagate_at_launch = true
175+
}
176176
}
177177

178178
resource "aws_elb" "elb" {

outputs.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
output "rabbitmq_elb_dns" {
2+
value = "${aws_elb.elb.dns_name}"
3+
}

variables.tf

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
variable "access_key" {}
2-
variable "secret_key" {}
3-
variable "region" {}
41
variable "vpc_id" {}
2+
variable "region" {}
53
variable "ssh_key_name" {}
64
variable "count" {
75
description = "Number of RabbitMQ nodes"
@@ -11,8 +9,12 @@ variable "subnet_ids" {
119
description = "Subnets for RabbitMQ nodes"
1210
type = "list"
1311
}
14-
variable "security_group_ids" {
15-
description = "Security groups which should have access to ELB (amqp + http ports) and nodes (ssh port)"
12+
variable "ssh_security_group_ids" {
13+
description = "Security groups which should have SSH access to nodes."
14+
type = "list"
15+
}
16+
variable "elb_security_group_ids" {
17+
description = "Security groups which should have access to ELB (amqp + http ports)."
1618
type = "list"
1719
}
1820
variable "admin_password" {

0 commit comments

Comments
 (0)