Add Elasticache resources for Discourse to Mesos cluster
This commit is contained in:
Родитель
20f1584217
Коммит
b75dba7599
|
@ -0,0 +1,19 @@
|
|||
module "discourse-production" {
|
||||
source = "./modules/discourse"
|
||||
|
||||
environment = "production"
|
||||
vpc_id = "${aws_vpc.apps-production-vpc.id}"
|
||||
discourse_elasticache_instance_size = "cache.t2.medium"
|
||||
service_security_group_id = "${module.mesos-cluster-production.mesos-cluster-slave-sg-id}"
|
||||
elasticache_subnet_group = "${aws_elasticache_subnet_group.elasticache-production-subnet-group.name}"
|
||||
}
|
||||
|
||||
module "discourse-staging" {
|
||||
source = "./modules/discourse"
|
||||
|
||||
environment = "staging"
|
||||
vpc_id = "${aws_vpc.apps-staging-vpc.id}"
|
||||
discourse_elasticache_instance_size = "cache.t2.micro"
|
||||
service_security_group_id = "${module.mesos-cluster-staging.mesos-cluster-slave-sg-id}"
|
||||
elasticache_subnet_group = "${aws_elasticache_subnet_group.elasticache-staging-subnet-group.name}"
|
||||
}
|
|
@ -14,6 +14,7 @@ module "mesos-cluster-staging" {
|
|||
subnet2 = "${aws_subnet.apps-staging-1c.id}"
|
||||
subnet3 = "${aws_subnet.apps-staging-1d.id}"
|
||||
}
|
||||
|
||||
module "mesos-cluster-production" {
|
||||
source = "./modules/mesos-cluster"
|
||||
# provider vars
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
variable "vpc_id" {}
|
||||
variable "discourse_elasticache_instance_size" {}
|
||||
variable "elasticache_subnet_group" {}
|
||||
variable "service_security_group_id" {}
|
||||
variable "environment" {}
|
||||
|
||||
resource "aws_security_group" "discourse-redis-sg" {
|
||||
name = "discourse-redis-shared-sg"
|
||||
description = "discourse elasticache SG"
|
||||
vpc_id = "${var.vpc_id}"
|
||||
}
|
||||
|
||||
resource "aws_security_group_rule" "discourse-redis-sg-allowredisfromslaves" {
|
||||
type = "ingress"
|
||||
from_port = 6379
|
||||
to_port = 6379
|
||||
protocol = "tcp"
|
||||
source_security_group_id = "${var.service_security_group_id}"
|
||||
security_group_id = "${aws_security_group.discourse-redis-sg.id}"
|
||||
}
|
||||
|
||||
resource "aws_security_group_rule" "discourse-redis-sg-allowegress" {
|
||||
type = "egress"
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
protocol = "-1"
|
||||
source_security_group_id = "${var.service_security_group_id}"
|
||||
security_group_id = "${aws_security_group.discourse-redis-sg.id}"
|
||||
}
|
||||
|
||||
resource "aws_elasticache_cluster" "discourse-redis-ec" {
|
||||
cluster_id = "discourse-${var.environment}"
|
||||
engine = "redis"
|
||||
engine_version = "2.8.24"
|
||||
node_type = "${var.discourse_elasticache_instance_size}"
|
||||
port = 6379
|
||||
num_cache_nodes = 1
|
||||
parameter_group_name = "default.redis2.8"
|
||||
subnet_group_name = "${var.elasticache_subnet_group}"
|
||||
security_group_ids = ["${aws_security_group.discourse-redis-sg.id}"]
|
||||
tags {
|
||||
Name = "discourse-${var.environment}-redis"
|
||||
app = "redis"
|
||||
env = "${var.environment}"
|
||||
project = "discourse"
|
||||
}
|
||||
}
|
|
@ -1,9 +1,3 @@
|
|||
resource "aws_elasticache_subnet_group" "elasticache-shared-subnet-group" {
|
||||
name = "elasticache-shared-subnet-group"
|
||||
subnet_ids = ["${aws_subnet.apps-shared-1a.id}", "${aws_subnet.apps-shared-1c.id}", "${aws_subnet.apps-shared-1d.id}"]
|
||||
description = "Subnet group for shared VPC"
|
||||
}
|
||||
|
||||
resource "aws_security_group" "sensu-redis-sg" {
|
||||
name = "sensu-redis-shared-sg"
|
||||
description = "Sensu elasticache SG"
|
||||
|
|
20
network.tf
20
network.tf
|
@ -371,3 +371,23 @@ resource "aws_route_table_association" "apps-shared-1d-rtbassoc" {
|
|||
route_table_id = "${aws_route_table.apps-shared-rt.id}"
|
||||
subnet_id = "${aws_subnet.apps-shared-1d.id}"
|
||||
}
|
||||
|
||||
# Elasticache subnet groups
|
||||
|
||||
resource "aws_elasticache_subnet_group" "elasticache-shared-subnet-group" {
|
||||
name = "elasticache-shared-subnet-group"
|
||||
subnet_ids = ["${aws_subnet.apps-shared-1a.id}", "${aws_subnet.apps-shared-1c.id}", "${aws_subnet.apps-shared-1d.id}"]
|
||||
description = "Subnet group for shared VPC"
|
||||
}
|
||||
|
||||
resource "aws_elasticache_subnet_group" "elasticache-staging-subnet-group" {
|
||||
name = "elasticache-staging-subnet-group"
|
||||
subnet_ids = ["${aws_subnet.apps-staging-1a.id}", "${aws_subnet.apps-staging-1c.id}", "${aws_subnet.apps-staging-1d.id}"]
|
||||
description = "Subnet group for staging VPC"
|
||||
}
|
||||
|
||||
resource "aws_elasticache_subnet_group" "elasticache-production-subnet-group" {
|
||||
name = "elasticache-production-subnet-group"
|
||||
subnet_ids = ["${aws_subnet.apps-production-1a.id}", "${aws_subnet.apps-production-1c.id}", "${aws_subnet.apps-production-1d.id}"]
|
||||
description = "Subnet group for production VPC"
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче