Next - Terraform + CloudFormation = RabbitMQ Cluster with ASG

resource "aws_security_group" "rabbitmq" {
  name   = "rabbitmq"
  vpc_id = "${aws_vpc.vpc.id}"

  ingress {
    protocol    = "tcp"
    from_port   = 5439
    to_port     = 5439
    cidr_blocks = ["0.0.0.0/0"]
  }

  ingress {
    protocol    = "icmp"
    from_port   = -1
    to_port     = -1
    cidr_blocks = ["0.0.0.0/0"]
  }

  egress {
    protocol    = -1
    from_port   = 0
    to_port     = 0
    cidr_blocks = ["0.0.0.0/0"]
  }
}

resource "template_file" "rabbitmq_cloudformation" {
  template = "${file("rabbitmq.cloudformation")}"

  vars {
    rabbitmq_public_subnet_id  = "${element(split(",",

terraform_remote_state.shared.output.public_subnet_ids), 0)}"
    rabbitmq_security_group_id = "${aws_security_group.rabbitmq.id}"
  }
}

resource "aws_cloudformation_stack" "heavy_rabbitmq" {
  name          = "heavy-rabbitmq"
  template_body = "${template_file.rabbitmq_cloudformation.rendered}"

  parameters {
    MasterUsername     = "master"
    MasterUserPassword = "MasterPassword123"
  }
}

output "rabbitmq_endpoint" {
  value = "${aws_cloudformation_stack.heavy_rabbitmq.outputs.ClusterEndpoint}"
}

Comments

Popular posts from this blog

ActiveMQ, easy to use open source message oriented middleware (MOM)

Basic Send Message to MQ with Java and IBM MQ JMS

MySQL Error Invalid Table or Database Name