Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
remove providers from modules
Browse files Browse the repository at this point in the history
  • Loading branch information
robertpeteuil committed Jul 22, 2020
1 parent 9b2519e commit d118562
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 103 deletions.
52 changes: 0 additions & 52 deletions terraform/modules/consul-demo-cluster/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions terraform/modules/consul-demo-cluster/main.tf
Original file line number Diff line number Diff line change
@@ -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}"
Expand Down
33 changes: 14 additions & 19 deletions terraform/modules/consul-demo-cluster/outputs.tf
Original file line number Diff line number Diff line change
@@ -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
}
9 changes: 2 additions & 7 deletions terraform/modules/consul-demo-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 = ""
Expand Down
12 changes: 7 additions & 5 deletions terraform/modules/link-vpc/main.tf
Original file line number Diff line number Diff line change
@@ -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, )
Expand Down
8 changes: 0 additions & 8 deletions terraform/modules/link-vpc/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
24 changes: 20 additions & 4 deletions terraform/multi-region-demo/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions terraform/multi-region-demo/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Main Cluster Region
output "main_region" {
value = module.cluster_main.aws_region
value = var.aws_region
}

output "main_consul_lb" {
Expand Down Expand Up @@ -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" {
Expand Down
5 changes: 4 additions & 1 deletion terraform/single-region-demo/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion terraform/single-region-demo/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Outputs

output "main_cluster_region" {
value = module.cluster_main.aws_region
value = var.aws_region
}

output "main_consul_lb" {
Expand Down

0 comments on commit d118562

Please sign in to comment.