Bläddra i källkod

added new module dns

Roberto Barbosa 8 år sedan
förälder
incheckning
5b13c31afd

+ 18 - 0
dns/main.tf

@@ -0,0 +1,18 @@
+/***************************************************
+* DNS LOCAL ADDRESS
+****************************************************/
+resource "aws_route53_zone" "main" {
+  count = "${var.create_dns_domain}"
+  name = "${var.stack_name}.local"
+  vpc_id = "${var.vpc_id}"
+}
+
+resource "aws_route53_record" "database" {
+  count = "${var.create_dns_record}"
+
+   zone_id = "${aws_route53_zone.main.zone_id}"
+   name = "${var.dns_record}"
+   type = "CNAME"
+   ttl = "300"
+   records = ["${var.dns_cname}"]
+}

+ 24 - 0
dns/variables.tf

@@ -0,0 +1,24 @@
+variable "create_dns_domain" {
+  default = true
+}
+
+variable "create_dns_record" {
+  default = true
+}
+
+variable "stack_name" {
+    default = ""
+}
+
+variable "vpc_id" {
+    default = ""
+}
+
+
+variable "dns_record" {
+  type = "string"
+}
+
+variable "dns_cname" {
+  type = "string"
+}

+ 10 - 26
examples/alb/main.tf

@@ -1,36 +1,20 @@
-variable "region" {}
-variable "aws-profile" {}
-variable "stack_name" {}
-
-provider "aws" {
-  region  = "${var.region}"
-  profile = "${var.aws-profile}"
-}
-
-############################################################
-# This data provider is used if you deployed the vpc example
-############################################################
-data "terraform_remote_state" "base" {
-    backend = "local"
-    config {
-        path = "../base/terraform.tfstate"
-    }
+module "app_subnets" {
+  source = "/Users/rnrbarbosa/repos/cloud-aws-stack/subnets"
 
+  vpc_id = "${data.terraform_remote_state.base.vpc_id}"
+  stack_name = "${var.stack_name}"
+  prefix = "app"
+  subnet_cidrs = ["10.0.50.0/24","10.0.51.0/24","10.0.52.0/24"]
+  public_route_table = "${data.terraform_remote_state.base.public_route_table[0]}"
 }
-# Automatically get the Availability Zones
-data "aws_availability_zones" "available" {}
 
 module "alb" {
   source = "/Users/rnrbarbosa/repos/cloud-aws-stack/alb/"
-  
-  # Specify directly the below values if no state file is available
-  vpc_id = "${data.terraform_remote_state.base.vpc_id}"
-  alb_secgroups = ["${data.terraform_remote_state.base.inbound}"]
 
+  vpc_id = "${data.terraform_remote_state.base.vpc_id}"
   stack_name = "${var.stack_name}"
+  alb_secgroups = ["${data.terraform_remote_state.base.inbound}"]
+  app_subnets = ["${split(",", module.app_subnets.subnets)}"]
   azs = ["${data.aws_availability_zones.available.names[0]}","${data.aws_availability_zones.available.names[1]}","${data.aws_availability_zones.available.names[2]}"]
-
-  app_subnet_ids = ["10.0.11.0/24","10.0.12.0/24","10.0.13.0/24"]
-
 }
 

+ 1 - 0
examples/alb/outputs.tf

@@ -5,3 +5,4 @@ output "nuxeo_url_alb" {
 output "nuxeo_url" {
   value = "${module.alb.nuxeo_url}"
 }
+

+ 17 - 0
examples/alb/provider.tf

@@ -0,0 +1,17 @@
+variable "region" {}
+variable "aws-profile" {}
+variable "stack_name" {}
+
+provider "aws" {
+  region  = "${var.region}"
+  profile = "${var.aws-profile}"
+}
+
+data "terraform_remote_state" "base" {
+    backend = "local"
+    config {
+        path = "../base/terraform.tfstate"
+    }
+}
+
+data "aws_availability_zones" "available" {}

+ 14 - 24
examples/rds/main.tf

@@ -1,36 +1,26 @@
-variable "region" {}
-variable "aws-profile" {}
-variable "stack_name" {}
+module "db_subnets" {
+	source = "../../../cloud-aws-stack/subnets"
 
-provider "aws" {
-  region  = "${var.region}"
-  profile = "${var.aws-profile}"
+  	vpc_id = "${data.terraform_remote_state.base.vpc_id}"
+	stack_name = "${var.stack_name}"
+        prefix = "db"
+	subnet_cidrs = ["10.0.60.0/24","10.0.61.0/24","10.0.62.0/24"]
+	public_route_table = "${data.terraform_remote_state.base.public_route_table[0]}"
 }
 
-############################################################
-# This data provider is used if you deployed the vpc example
-############################################################
-data "terraform_remote_state" "base" {
-    backend = "local"
-    config {
-        path = "${path.module}/../vpc/terraform.tfstate"
-    }
-}
-
-# Automatically get the Availability Zones
-data "aws_availability_zones" "available" {}
-
 module "rds" {
-  source = "git::https://github.com/nuxeo/cloud-aws-stack.git//rds"
+  #source = "git::https://github.com/nuxeo/cloud-aws-stack.git//rds"
+  source = "../../../cloud-aws-stack/rds"
 
-  # Specify VPC id if you did not deploy one with terraform
   vpc_id = "${data.terraform_remote_state.base.vpc_id}"
-
   region = "${var.region}"
   stack_name = "${var.stack_name}"
+  
   database_name = "nuxeo-${var.stack_name}"
-  db_subnet_ids = ["10.0.111.0/24","10.0.112.0/24","10.0.113.0/24"]
+  db_subnets = ["${split(",", module.db_subnets.subnets)}"]
   security_group_ids = [""]
   azs = ["${data.aws_availability_zones.available.names[0]}","${data.aws_availability_zones.available.names[1]}","${data.aws_availability_zones.available.names[2]}"]
-}
 
+  create_dns_domain = true
+  create_dns_record = true
+}

+ 17 - 0
examples/rds/provider.tf

@@ -0,0 +1,17 @@
+variable "region" {}
+variable "aws-profile" {}
+variable "stack_name" {}
+
+provider "aws" {
+  region  = "${var.region}"
+  profile = "${var.aws-profile}"
+}
+
+data "terraform_remote_state" "base" {
+    backend = "local"
+    config {
+        path = "${path.module}/../base/terraform.tfstate"
+    }
+}
+
+data "aws_availability_zones" "available" {}

+ 11 - 12
examples/s3/main.tf

@@ -1,17 +1,16 @@
-variable "region" {}
-variable "aws-profile" {}
-variable "stack_name" {}
-
-provider "aws" {
-  region  = "${var.region}"
-  profile = "${var.aws-profile}"
-}
-
-############################################################
-# Module usage
-############################################################
 module "s3" {
   source = "/Users/rnrbarbosa/repos/cloud-aws-stack/s3"
   stack_name = "${var.stack_name}"
 }
 
+output "s3_binstore_name" {
+	value = "${module.s3.s3_binstore_name}"
+}
+
+output "s3_bkstore_name" {
+	value = "${module.s3.s3_bkstore_name}"
+}
+
+output "s3_logstore_name" {
+	value = "${module.s3.s3_logstore_name}"
+}

+ 9 - 0
examples/s3/provider.tf

@@ -0,0 +1,9 @@
+variable "region" {}
+variable "aws-profile" {}
+variable "stack_name" {}
+
+provider "aws" {
+  region  = "${var.region}"
+  profile = "${var.aws-profile}"
+}
+

+ 3 - 15
examples/vpc/main.tf

@@ -1,20 +1,8 @@
-# Configure the AWS Provider
-
-variable region {}
-variable aws-profile {}
-
-provider "aws" {
-  region = "${var.region}"
-  profile = "${var.aws-profile}"
-}
-
-
 module "new-vpc" {
-  source = "git::https://github.com/nuxeo/cloud-aws-stack.git//vpc"
+  # source = "git::https://nuxeo-tf:nuxeo@continuousdelivery.nuxeocloud.com/nuxeo/cloud-aws-stack.git//vpc"
+  source = "/Users/rnrbarbosa/repos/cloud-aws-stack/vpc"
 
-  cloud_name = "vpc-cloud-v1"
+  cloud_name = "${var.cloud_name}"
   cidr = "10.0.0.0/16"
-
-  enable_nat_gateway = true
 }
 

+ 8 - 3
examples/vpc/outputs.tf

@@ -1,6 +1,3 @@
-############################################################
-# This variables are to be used by other modules
-############################################################
 output "vpc_id" {
   value = "${module.new-vpc.vpc_id}"
 }
@@ -13,3 +10,11 @@ output "public" {
 output "private" {
   value = "${module.new-vpc.private_subnet}"
 }
+
+output "public_route_table" {
+	value = "${module.new-vpc.public_route_table_ids}"
+}
+
+output "igw" {
+	value = "${module.new-vpc.igw}"
+}

+ 11 - 0
examples/vpc/provider.tf

@@ -0,0 +1,11 @@
+# Configure the AWS Provider
+
+variable region {}
+variable aws-profile {}
+variable cloud_name {}
+
+provider "aws" {
+  region = "${var.region}"
+  profile = "${var.aws-profile}"
+}
+