|
@@ -12,7 +12,9 @@
|
|
|
#-------------------
|
|
|
# VARIABLES
|
|
|
#-------------------
|
|
|
-variable "stack_name" {}
|
|
|
+variable "stack_name" {
|
|
|
+ default = "Name for this stack like customer-Name or project-name"
|
|
|
+}
|
|
|
variable "aws_region" {}
|
|
|
variable "vpc_id" {}
|
|
|
|
|
@@ -126,17 +128,17 @@ data "aws_availability_zones" "all" {}
|
|
|
#-------------
|
|
|
# DNS Entry for Cloud Customer
|
|
|
#-------------
|
|
|
-resource "aws_route53_record" "dns" {
|
|
|
- zone_id = "ID:Z1EFT3O5K9NMCJ" // Zone ID for nuxeocloud.com
|
|
|
- name = "${name}"
|
|
|
- type = "CNAME"
|
|
|
- ttl = "300"
|
|
|
- weighted_routing_policy {
|
|
|
- weight = 90
|
|
|
- }
|
|
|
- set_identifier = "${var.stack_name}"
|
|
|
- records = ["${var.stack_name}.nuxeocloud.com"]
|
|
|
-}
|
|
|
+#resource "aws_route53_record" "dns" {
|
|
|
+# zone_id = "Z1EFT3O5K9NMCJ" // Zone ID for nuxeocloud.com
|
|
|
+# name = "${name}"
|
|
|
+# type = "CNAME"
|
|
|
+# ttl = "300"
|
|
|
+# weighted_routing_policy {
|
|
|
+# weight = 90
|
|
|
+# }
|
|
|
+# set_identifier = "${var.stack_name}"
|
|
|
+# records = ["${var.stack_name}.nuxeocloud.com"]
|
|
|
+#}
|
|
|
|
|
|
#-------------
|
|
|
# S3 Bucket
|
|
@@ -146,7 +148,7 @@ resource "random_id" "customer" {
|
|
|
}
|
|
|
|
|
|
resource "aws_s3_bucket" "bucket" {
|
|
|
- bucket = "cloud-${random_id.customer.b64}"
|
|
|
+ bucket = "nuxeo-${random_id.customer.hex}"
|
|
|
acl = "private"
|
|
|
|
|
|
tags {
|
|
@@ -337,7 +339,7 @@ resource "aws_security_group" "sg_external_elb" {
|
|
|
}
|
|
|
|
|
|
resource "aws_security_group" "sg_internal" {
|
|
|
- name = "${format("%s-sg-external-elb", var.stack_name)}"
|
|
|
+ name = "${format("%s-sg-internal-elb", var.stack_name)}"
|
|
|
vpc_id = "${var.vpc_id}"
|
|
|
description = "Allows external ELB traffic"
|
|
|
|
|
@@ -435,13 +437,13 @@ resource "aws_elb" "elb" {
|
|
|
instance_protocol = "http"
|
|
|
}
|
|
|
|
|
|
- listener {
|
|
|
- lb_port = 443
|
|
|
- lb_protocol = "https"
|
|
|
- instance_port = 80
|
|
|
- instance_protocol = "http"
|
|
|
- ssl_certificate_id = "${var.ssl_certificate_id}"
|
|
|
- }
|
|
|
+# listener {
|
|
|
+# lb_port = 443
|
|
|
+# lb_protocol = "https"
|
|
|
+# instance_port = 80
|
|
|
+# instance_protocol = "http"
|
|
|
+# #ssl_certificate_id = "${var.ssl_certificate_id}"
|
|
|
+# }
|
|
|
|
|
|
health_check {
|
|
|
healthy_threshold = 2
|
|
@@ -469,19 +471,19 @@ resource "aws_elb" "elb" {
|
|
|
# RDS Postgresql Database
|
|
|
#-------------------
|
|
|
resource "aws_db_instance" "main_rds_instance" {
|
|
|
- identifier = "${var.stack_name}-db"
|
|
|
+ identifier = "db-${var.stack_name}"
|
|
|
allocated_storage = "${var.rds_allocated_storage}"
|
|
|
engine = "postgres"
|
|
|
engine_version = "${var.rds_engine_version}"
|
|
|
instance_class = "${var.rds_instance_class}"
|
|
|
- name = "${var.stack_name}-nuxeo-db}"
|
|
|
+ name = "${var.stack_name}"
|
|
|
username = "${var.database_user}"
|
|
|
password = "${var.database_password}"
|
|
|
// Because we're assuming a VPC, we use this option, but only one SG id
|
|
|
vpc_security_group_ids = ["${aws_security_group.sg_internal.id}"]
|
|
|
// We're creating a subnet group in the module and passing in the name
|
|
|
db_subnet_group_name = "${var.stack_name}-db-subnet-group"
|
|
|
- parameter_group_name = "${var.db_parameter_group}"
|
|
|
+ parameter_group_name = "default.postgres9.4"
|
|
|
// We want the multi-az setting to be toggleable, but off by default
|
|
|
multi_az = "${var.rds_is_multi_az}"
|
|
|
storage_type = "${var.rds_storage_type}"
|
|
@@ -493,11 +495,11 @@ resource "aws_db_instance" "main_rds_instance" {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#resource "aws_db_subnet_group" "main_db_subnet_group" {
|
|
|
-# name = "${var.stack_name}-db--subnetgrp"
|
|
|
-# description = "RDS subnet group"
|
|
|
-# subnet_ids = ["${aws_subnet.db_private.1.id}", "${aws_subnet.db_private.2.id}"]
|
|
|
-#}
|
|
|
+resource "aws_db_subnet_group" "main_db_subnet_group" {
|
|
|
+ name = "${var.stack_name}-db-subnet-group"
|
|
|
+ description = "RDS private subnet group"
|
|
|
+ subnet_ids = ["${aws_subnet.db_private.0.id}", "${aws_subnet.db_private.1.id}"]
|
|
|
+}
|
|
|
|
|
|
|
|
|
#-------------------
|
|
@@ -506,13 +508,13 @@ resource "aws_db_instance" "main_rds_instance" {
|
|
|
resource "aws_elasticache_cluster" "redis" {
|
|
|
cluster_id = "${var.stack_name}"
|
|
|
engine = "redis"
|
|
|
- engine_version = "3.2"
|
|
|
+ engine_version = "3.2.4"
|
|
|
node_type = "cache.t2.micro"
|
|
|
port = "6379"
|
|
|
num_cache_nodes = 1
|
|
|
parameter_group_name = "default.redis3.2"
|
|
|
- #subnet_group_name = "${aws_elasticache_subnet_group.default.name}"
|
|
|
- #security_group_ids = ["${aws_security_group.sg_private.id}"]
|
|
|
+ subnet_group_name = "${aws_elasticache_subnet_group.redis.name}"
|
|
|
+ security_group_ids = ["${aws_security_group.sg_internal.id}"]
|
|
|
tags {
|
|
|
Name = "Redis ElasticCache"
|
|
|
billing-category = "customers"
|
|
@@ -521,8 +523,14 @@ resource "aws_elasticache_cluster" "redis" {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+resource "aws_elasticache_subnet_group" "redis" {
|
|
|
+ name = "${var.stack_name}-redis-subnet-group"
|
|
|
+ description = "Private subnets for the ElastiCache instances"
|
|
|
+ subnet_ids = ["${aws_subnet.db_private.0.id}", "${aws_subnet.db_private.1.id}"]
|
|
|
+}
|
|
|
+
|
|
|
#-------------------
|
|
|
-# Elastic Cache Redis
|
|
|
+# Create Nuxeo Ubuntu Instance
|
|
|
#-------------------
|
|
|
# Create a new instance of the latest Ubuntu on an
|
|
|
# t2.micro node with an AWS Tag naming it "Nuxeo"
|
|
@@ -543,6 +551,7 @@ resource "aws_instance" "nuxeo" {
|
|
|
ami = "${data.aws_ami.ubuntu.id}"
|
|
|
instance_type = "t2.micro"
|
|
|
key_name = "${aws_key_pair.deployer.id}"
|
|
|
+ subnet_id = "${aws_subnet.private.id}"
|
|
|
tags {
|
|
|
Name = "Nuxeo"
|
|
|
billing-category = "customers"
|