| 
														
															@@ -1,11 +1,15 @@ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 /* 
														 | 
														
														 | 
														
															 /* 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 * https://wiki.nuxeo.com/display/INFRA/Cloud+Provisioning 
														 | 
														
														 | 
														
															 * https://wiki.nuxeo.com/display/INFRA/Cloud+Provisioning 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-* 1) Create Public Subnet with a /24 size. One private Subnet to run Nuxeo and at least 2 Private Subnets for Data 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+* 1) Create Subnets for the Stack 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+*     - On Public with a /24 size.  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+*     - One private Subnet to run Nuxeo  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+*     - at least 2 Private Subnets for Databases 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 * 2) Create a NAT Gateway in one of the Public Subnets 
														 | 
														
														 | 
														
															 * 2) Create a NAT Gateway in one of the Public Subnets 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 * 3) Create a Route with the Internet Gateway as default route, associate it with the Public Subnet(s) 
														 | 
														
														 | 
														
															 * 3) Create a Route with the Internet Gateway as default route, associate it with the Public Subnet(s) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 * 4) Create a Route with the NAT Gateway as default route, *that should be associated to all Private Subnets when they are created* 
														 | 
														
														 | 
														
															 * 4) Create a Route with the NAT Gateway as default route, *that should be associated to all Private Subnets when they are created* 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-* 5) Create a Security Group for Bastion Hosts that accepts SSH from anywhere 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-* 6) Create a Security Group for ELBs that accepts HTTP and HTTPS from anywhere 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+* 5) Create a Security Group for ELBs that accepts HTTP and HTTPS from anywhere 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+* 6) Create a Security Group for Bastion Hosts that accepts SSH from anywhere 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+*  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 * 7) Create a Bastion Host with bastion host SG associated to ti, install NTP and Userify on it 
														 | 
														
														 | 
														
															 * 7) Create a Bastion Host with bastion host SG associated to ti, install NTP and Userify on it 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 */ 
														 | 
														
														 | 
														
															 */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -20,7 +24,7 @@ module "net" { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   source = "./net/" 
														 | 
														
														 | 
														
															   source = "./net/" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															   stack_name = "${var.stack_name}"   
														 | 
														
														 | 
														
															   stack_name = "${var.stack_name}"   
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  region = "us-west-2" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  region = "${var.aws_region}" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   vpc_id = "${var.vpc_id}" 
														 | 
														
														 | 
														
															   vpc_id = "${var.vpc_id}" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															   public_subnets = ["10.0.10.0/24"] 
														 | 
														
														 | 
														
															   public_subnets = ["10.0.10.0/24"] 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -30,23 +34,23 @@ module "net" { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 #------------- 
														 | 
														
														 | 
														
															 #------------- 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# DNS Entry for Cloud Customer 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+#DNS Entry for Cloud Customer 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 #------------- 
														 | 
														
														 | 
														
															 #------------- 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#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"] 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+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 buckets:w for Nuxeo and for Backups 
														 | 
														
														 | 
														
															 # S3 buckets:w for Nuxeo and for Backups 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#------------------------------------- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+# ------------------------------------- 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 module "s3" { 
														 | 
														
														 | 
														
															 module "s3" { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   source = "./s3/" 
														 | 
														
														 | 
														
															   source = "./s3/" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   stack_name = "${var.stack_name}" 
														 | 
														
														 | 
														
															   stack_name = "${var.stack_name}" 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -54,9 +58,9 @@ module "s3" { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#------------------------- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+# ------------------------- 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 # RDS Postgres Database 
														 | 
														
														 | 
														
															 # RDS Postgres Database 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#------------------------- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+# ------------------------- 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 module "rds" { 
														 | 
														
														 | 
														
															 module "rds" { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   source = "./rds/" 
														 | 
														
														 | 
														
															   source = "./rds/" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   region = "${var.aws_region}" 
														 | 
														
														 | 
														
															   region = "${var.aws_region}" 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -84,42 +88,19 @@ module "elasticcache" { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	private_subnet_ids  = ["${module.net.db_private}"] 
														 | 
														
														 | 
														
															 	private_subnet_ids  = ["${module.net.db_private}"] 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+#------------------------- 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+# EC2 Instances 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+#------------------------- 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+module "nuxeo" { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  source = "./instance/" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  # Variables for creating an instance 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  stack_name = "${var.stack_name}-nuxeo" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  instance_name = "${var.stack_name}-nuxeo-instance" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  os_release = "xenial" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  instance_type = "t2.micro" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  public_key_path ="${var.public_key_path}" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+#  public_key_path="/path/to/my/pub_key" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  subnet_id="${element(module.net.private_subnets, 0)}" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# #------------------------------- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# # Create Nuxeo Ubuntu Instance 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# #------------------------------- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# # Create a new instance of the latest Ubuntu on an 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# # t2.micro node with an AWS Tag naming it "Nuxeo" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# data "aws_ami" "ubuntu" { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#   most_recent = true 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#   filter { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#     name = "name" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#     values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"] 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#   } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#   filter { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#     name = "virtualization-type" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#     values = ["hvm"] 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#   } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#   owners = ["099720109477"] # Canonical 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# 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" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#       billing-subcategory = "${var.stack_name}" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#       role= "nuxeo.instance" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#     } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# #--------------------- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# # Deployer SSH keys  
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# #-------------------- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# resource "aws_key_pair" "deployer" { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#   key_name = "deployer-key"  
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-#   public_key = "${file(var.public_key_path)}" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# } 
														 | 
														
														 | 
														
															 
														 |