diff --git a/terraform/modules/consul-demo-cluster/README.md b/terraform/modules/consul-demo-cluster/README.md deleted file mode 100644 index f09ae64..0000000 --- a/terraform/modules/consul-demo-cluster/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# consul-demo-cluster module - -## Required Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|:----:|:-----:|:-----:| -| project\_name | Project Name - used to set unique resource names | string | n/a | yes | -| route53\_zone\_id | Route 53 zone into which to place hostnames | string | n/a | yes | -| ssh\_key\_name | Name of existing AWS ssh key | string | n/a | yes | -| top\_level\_domain | The top-level domain to put all Route53 records | string | n/a | yes | - -## Optional Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|:----:|:-----:|:-----:| -| ami\_owner | AWS account which owns AMIs | string | `"753646501470"` | no | -| ami\_prefix | prefix of AMI images to use when building instances | string | `"consul-demo"` | no | -| aws\_region | Region into which to deploy | string | `"us-west-2"` | no | -| client\_db\_count | The number of client machines to create in each region | string | `"1"` | no | -| client\_listing\_count | The number of listing machines to create in each region | string | `"2"` | no | -| client\_machine\_type | The machine type \(size\) to deploy | string | `"t2.micro"` | no | -| client\_product\_count | The number of product machines to create in each region | string | `"2"` | no | -| client\_webclient\_count | The number of webclients to create in each region | string | `"2"` | no | -| consul\_acl\_dc | Consul ACL cluster name | string | `"dc1"` | no | -| consul\_dc | Consul cluster DC name | string | `"dc1"` | no | -| consul\_lic | License file content for Consul Enterprise | string | `""` | no | -| consul\_servers\_count | How many Consul servers to create in each region | string | `"3"` | no | -| hashi\_tags | Tags to apply to resources | map | `` | no | -| internal\_netblock | Global netblock | string | `"10.0.0.0/8"` | no | -| server\_machine\_type | The machine type \(size\) to deploy | string | `"t2.micro"` | no | -| vpc\_netblock | The netblock for this deployment's VPC | string | `"10.0.0.0/16"` | no | - -## Outputs - -| Name | Description | -|------|-------------| -| aws\_region | Region into which to deploy | -| consul\_acl\_dc | Consul ACL cluster name | -| consul\_dc | Consul cluster DC name | -| consul\_lb | Consul Server Load Balancer FQDN | -| consul\_servers | Consul Server FQDNs | -| consul\_servers\_private\_ip | Consul Server Private IP Addresses | -| listing\_api\_servers | Listing Server FQDNs | -| mongo\_servers | Mongo Server FQDNs | -| product\_api\_servers | Product Server FQDNs | -| public\_subnets | The public subnets for this deployment | -| vpc\_id | VPC ID | -| vpc\_netblock | The netblock for this deployment's VPC | -| vpc\_public\_route\_table\_id | ID of public route table | -| webclient\_lb | Webclient Load Balancer FQDN | -| webclient\_servers | Webclient Server FQDNs | - diff --git a/terraform/modules/consul-demo-cluster/main.tf b/terraform/modules/consul-demo-cluster/main.tf index 94f33e6..4a4cdc8 100644 --- a/terraform/modules/consul-demo-cluster/main.tf +++ b/terraform/modules/consul-demo-cluster/main.tf @@ -1,9 +1,5 @@ # main -provider "aws" { - region = var.aws_region -} - # Create Unique ID to allow multiple deployments of module locals { unique_proj_id = "${var.project_name}-${var.consul_dc}" diff --git a/terraform/modules/consul-demo-cluster/outputs.tf b/terraform/modules/consul-demo-cluster/outputs.tf index 01905ca..d44bc14 100644 --- a/terraform/modules/consul-demo-cluster/outputs.tf +++ b/terraform/modules/consul-demo-cluster/outputs.tf @@ -1,76 +1,71 @@ # Outputs -output "aws_region" { - description = "Region into which to deploy" - value = var.aws_region -} - output "consul_dc" { description = "Consul cluster DC name" - value = var.consul_dc + value = var.consul_dc } output "consul_acl_dc" { description = "Consul ACL cluster name" - value = var.consul_acl_dc + value = var.consul_acl_dc } output "vpc_id" { description = "VPC ID" - value = aws_vpc.prod.id + value = aws_vpc.prod.id } output "vpc_netblock" { description = "The netblock for this deployment's VPC" - value = var.vpc_netblock + value = var.vpc_netblock } output "public_subnets" { description = "The public subnets for this deployment" - value = aws_subnet.public.*.cidr_block + value = aws_subnet.public.*.cidr_block } output "vpc_public_route_table_id" { description = "ID of public route table" - value = aws_route_table.public.id + value = aws_route_table.public.id } output "consul_lb" { description = "Consul Server Load Balancer FQDN" - value = aws_route53_record.consul_lb_a_record.fqdn + value = aws_route53_record.consul_lb_a_record.fqdn } output "consul_servers" { description = "Consul Server FQDNs" - value = aws_route53_record.consul_a_records.*.fqdn + value = aws_route53_record.consul_a_records.*.fqdn } output "consul_servers_private_ip" { description = "Consul Server Private IP Addresses" - value = aws_instance.consul.*.private_ip + value = aws_instance.consul.*.private_ip } output "webclient_lb" { description = "Webclient Load Balancer FQDN" - value = aws_route53_record.webclient_lb_a_record.fqdn + value = aws_route53_record.webclient_lb_a_record.fqdn } output "webclient_servers" { description = "Webclient Server FQDNs" - value = aws_route53_record.webclient_a_records.*.fqdn + value = aws_route53_record.webclient_a_records.*.fqdn } output "listing_api_servers" { description = "Listing Server FQDNs" - value = aws_route53_record.listing_a_records.*.fqdn + value = aws_route53_record.listing_a_records.*.fqdn } output "mongo_servers" { description = "Mongo Server FQDNs" - value = aws_route53_record.mongo_a_records.*.fqdn + value = aws_route53_record.mongo_a_records.*.fqdn } output "product_api_servers" { description = "Product Server FQDNs" - value = aws_route53_record.product_a_records.*.fqdn + value = aws_route53_record.product_a_records.*.fqdn } diff --git a/terraform/modules/consul-demo-cluster/variables.tf b/terraform/modules/consul-demo-cluster/variables.tf index 4627576..36f62f3 100644 --- a/terraform/modules/consul-demo-cluster/variables.tf +++ b/terraform/modules/consul-demo-cluster/variables.tf @@ -5,8 +5,8 @@ variable "project_name" { } variable "hashi_tags" { - type = map(string) - description = "Tags to apply to resources" + type = map(string) + description = "Tags to apply to resources" default = { "TTL" = "24" @@ -29,11 +29,6 @@ variable "top_level_domain" { # Optional -variable "aws_region" { - description = "Region into which to deploy" - default = "us-west-2" -} - variable "consul_lic" { description = "License file content for Consul Enterprise" default = "" diff --git a/terraform/modules/link-vpc/main.tf b/terraform/modules/link-vpc/main.tf index 35540c4..e920f06 100644 --- a/terraform/modules/link-vpc/main.tf +++ b/terraform/modules/link-vpc/main.tf @@ -1,25 +1,27 @@ # Link two AWS VPCs and add Routes provider "aws" { - region = var.aws_region_main - alias = "main" + alias = "main" } provider "aws" { - region = var.aws_region_alt - alias = "alt" + alias = "alt" } data "aws_caller_identity" "alt" { provider = aws.alt } +data "aws_region" "alt" { + provider = aws.alt +} + resource "aws_vpc_peering_connection" "main" { provider = aws.main vpc_id = var.vpc_id_main peer_vpc_id = var.vpc_id_alt peer_owner_id = data.aws_caller_identity.alt.account_id - peer_region = var.aws_region_alt + peer_region = data.aws_region.alt.name auto_accept = false tags = merge({ "Name" = "prod-main-alt-link" }, { "Side" = "Requestor" }, var.hashi_tags, ) diff --git a/terraform/modules/link-vpc/variables.tf b/terraform/modules/link-vpc/variables.tf index f5a571d..5fad943 100644 --- a/terraform/modules/link-vpc/variables.tf +++ b/terraform/modules/link-vpc/variables.tf @@ -10,14 +10,6 @@ variable "hashi_tags" { } } -variable "aws_region_main" { - description = "Main AWS Region" -} - -variable "aws_region_alt" { - description = "Alt AWS Region" -} - variable "vpc_id_main" { description = "Main VPC ID" } diff --git a/terraform/multi-region-demo/main.tf b/terraform/multi-region-demo/main.tf index 870a575..59599cb 100644 --- a/terraform/multi-region-demo/main.tf +++ b/terraform/multi-region-demo/main.tf @@ -10,11 +10,23 @@ terraform { } } +provider "aws" { + region = var.aws_region + alias = "main" +} + +provider "aws" { + region = var.aws_region_alt + alias = "alt" +} + # Create MAIN Consul Connect cluster module "cluster_main" { source = "../modules/consul-demo-cluster" + providers = { + aws = aws.main + } - aws_region = var.aws_region consul_dc = var.consul_dc consul_acl_dc = var.consul_dc vpc_netblock = var.vpc_cidr_main @@ -32,8 +44,10 @@ module "cluster_main" { # Create ALTERNATE Consul Connect cluster module "cluster_alt" { source = "../modules/consul-demo-cluster" + providers = { + aws = aws.alt + } - aws_region = var.aws_region_alt consul_dc = var.consul_dc_alt consul_acl_dc = var.consul_dc vpc_netblock = var.vpc_cidr_alt @@ -51,13 +65,15 @@ module "cluster_alt" { # Link VPCs module "link_vpc" { source = "../modules/link-vpc" + providers = { + aws.main = aws.main + aws.alt = aws.alt + } - aws_region_main = module.cluster_main.aws_region vpc_id_main = module.cluster_main.vpc_id route_table_id_main = module.cluster_main.vpc_public_route_table_id cidr_block_main = module.cluster_main.vpc_netblock - aws_region_alt = module.cluster_alt.aws_region vpc_id_alt = module.cluster_alt.vpc_id route_table_id_alt = module.cluster_alt.vpc_public_route_table_id cidr_block_alt = module.cluster_alt.vpc_netblock diff --git a/terraform/multi-region-demo/outputs.tf b/terraform/multi-region-demo/outputs.tf index 63abf66..5a25055 100644 --- a/terraform/multi-region-demo/outputs.tf +++ b/terraform/multi-region-demo/outputs.tf @@ -2,7 +2,7 @@ # Main Cluster Region output "main_region" { - value = module.cluster_main.aws_region + value = var.aws_region } output "main_consul_lb" { @@ -35,7 +35,7 @@ output "main_product_api_servers" { # Alternate Cluster Outputs output "secondary_region" { - value = module.cluster_alt.aws_region + value = var.aws_region_alt } output "secondary_consul_lb" { diff --git a/terraform/single-region-demo/main.tf b/terraform/single-region-demo/main.tf index a69b44e..1ced2ed 100644 --- a/terraform/single-region-demo/main.tf +++ b/terraform/single-region-demo/main.tf @@ -9,11 +9,14 @@ terraform { } } +provider "aws" { + region = var.aws_region +} + # Create Consult Connect demo cluster module "cluster_main" { source = "../modules/consul-demo-cluster" - aws_region = var.aws_region consul_dc = var.consul_dc consul_acl_dc = var.consul_dc project_name = var.project_name diff --git a/terraform/single-region-demo/outputs.tf b/terraform/single-region-demo/outputs.tf index ff2f728..175400e 100644 --- a/terraform/single-region-demo/outputs.tf +++ b/terraform/single-region-demo/outputs.tf @@ -1,7 +1,7 @@ # Outputs output "main_cluster_region" { - value = module.cluster_main.aws_region + value = var.aws_region } output "main_consul_lb" {