Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

Commit

Permalink
re-introduce a flag to control route53.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgordon authored and ciphercules committed Mar 18, 2019
1 parent cb08254 commit 9a47766
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 32 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ ops_manager_ami = "ami-4f291f2f"
rds_instance_count = 1
dns_suffix = "example.com"
vpc_cidr = "10.0.0.0/16"
use_route53 = true
ssl_cert = <<EOF
-----BEGIN CERTIFICATE-----
Expand Down
6 changes: 2 additions & 4 deletions modules/control_plane/dns.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
locals {
use_route53 = "${var.region == "us-gov-west-1" ? 0 : 1}"
}

resource "aws_route53_record" "control_plane" {
count = "${var.use_route53}"

zone_id = "${var.zone_id}"
name = "plane.${var.env_name}.${var.dns_suffix}"
type = "CNAME"
Expand Down
2 changes: 1 addition & 1 deletion modules/control_plane/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "domain" {
value = "${aws_route53_record.control_plane.name}"
value = "${aws_route53_record.control_plane.*.name}"
}

output "lb_target_groups" {
Expand Down
3 changes: 3 additions & 0 deletions modules/control_plane/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ variable "zone_id" {
type = "string"
}

variable "use_route53" {
}

variable "dns_suffix" {
type = "string"
}
Expand Down
8 changes: 3 additions & 5 deletions modules/infra/dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,24 @@ locals {
resource_dns_name_servers = "${join(",", flatten(concat(aws_route53_zone.pcf_zone.*.name_servers, list(list("")))))}"
name_servers = "${var.hosted_zone == "" ? local.resource_dns_name_servers : local.data_dns_name_servers}"
hosted_zone_count = "${var.hosted_zone == "" ? 0 : 1}"

use_route53 = "${var.region == "us-gov-west-1" ? 0 : 1}"
}

data "aws_route53_zone" "pcf_zone" {
count = "${local.use_route53 ? local.hosted_zone_count : 0}"
count = "${var.use_route53 ? local.hosted_zone_count : 0}"

name = "${var.hosted_zone}"
}

resource "aws_route53_zone" "pcf_zone" {
count = "${local.use_route53 ? (1 - local.hosted_zone_count) : 0}"
count = "${var.use_route53 ? (1 - local.hosted_zone_count) : 0}"

name = "${var.env_name}.${var.dns_suffix}"

tags = "${merge(var.tags, map("Name", "${var.env_name}-hosted-zone"))}"
}

resource "aws_route53_record" "name_servers" {
count = "${local.use_route53 ? (1 - local.hosted_zone_count) : 0}"
count = "${var.use_route53 ? (1 - local.hosted_zone_count) : 0}"

zone_id = "${local.zone_id}"
name = "${var.env_name}.${var.dns_suffix}"
Expand Down
3 changes: 3 additions & 0 deletions modules/infra/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ variable "dns_suffix" {
type = "string"
}

variable "use_route53" {
}

variable "availability_zones" {
type = "list"
}
Expand Down
10 changes: 3 additions & 7 deletions modules/ops_manager/dns.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
locals {
use_route53 = "${var.region == "us-gov-west-1" ? 0 : 1}"
}

resource "aws_route53_record" "ops_manager_attached_eip" {
name = "pcf.${var.env_name}.${var.dns_suffix}"
zone_id = "${var.zone_id}"
type = "A"
ttl = 300
count = "${local.use_route53 ? var.vm_count : 0}"
count = "${var.use_route53 ? var.vm_count : 0}"

records = ["${coalesce(join("", aws_eip.ops_manager_attached.*.public_ip), aws_instance.ops_manager.private_ip)}"]
}
Expand All @@ -17,7 +13,7 @@ resource "aws_route53_record" "ops_manager_unattached_eip" {
zone_id = "${var.zone_id}"
type = "A"
ttl = 300
count = "${local.use_route53 && (var.vm_count < 1) ? 1 : 0}"
count = "${var.use_route53 && (var.vm_count < 1) ? 1 : 0}"

records = ["${aws_eip.ops_manager_unattached.*.public_ip}"]
}
Expand All @@ -27,7 +23,7 @@ resource "aws_route53_record" "optional_ops_manager" {
zone_id = "${var.zone_id}"
type = "A"
ttl = 300
count = "${local.use_route53 ? var.optional_count : 0}"
count = "${var.use_route53 ? var.optional_count : 0}"

records = ["${coalesce(join("", aws_eip.optional_ops_manager.*.public_ip), aws_instance.optional_ops_manager.private_ip)}"]
}
2 changes: 2 additions & 0 deletions modules/ops_manager/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ variable "additional_iam_roles_arn" {

variable "dns_suffix" {}

variable "use_route53" {}

variable "zone_id" {}

variable "bucket_suffix" {}
Expand Down
12 changes: 4 additions & 8 deletions modules/pas/dns.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
locals {
use_route53 = "${var.region == "us-gov-west-1" ? 0 : 1}"
}

resource "aws_route53_record" "wildcard_sys_dns" {
count = "${local.use_route53 ? 1 : 0}"
count = "${var.use_route53}"
zone_id = "${var.zone_id}"
name = "*.sys.${var.env_name}.${var.dns_suffix}"
type = "A"
Expand All @@ -16,7 +12,7 @@ resource "aws_route53_record" "wildcard_sys_dns" {
}

resource "aws_route53_record" "wildcard_apps_dns" {
count = "${local.use_route53 ? 1 : 0}"
count = "${var.use_route53}"
zone_id = "${var.zone_id}"
name = "*.apps.${var.env_name}.${var.dns_suffix}"
type = "A"
Expand All @@ -29,7 +25,7 @@ resource "aws_route53_record" "wildcard_apps_dns" {
}

resource "aws_route53_record" "ssh" {
count = "${local.use_route53 ? 1 : 0}"
count = "${var.use_route53}"
zone_id = "${var.zone_id}"
name = "ssh.sys.${var.env_name}.${var.dns_suffix}"
type = "A"
Expand All @@ -42,7 +38,7 @@ resource "aws_route53_record" "ssh" {
}

resource "aws_route53_record" "tcp" {
count = "${local.use_route53 ? 1 : 0}"
count = "${var.use_route53}"
zone_id = "${var.zone_id}"
name = "tcp.${var.env_name}.${var.dns_suffix}"
type = "A"
Expand Down
3 changes: 3 additions & 0 deletions modules/pas/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ variable "dns_suffix" {
type = "string"
}

variable "use_route53" {
}

variable "create_backup_pas_buckets" {
default = false
}
Expand Down
6 changes: 1 addition & 5 deletions modules/pks/dns.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
locals {
use_route53 = "${var.region == "us-gov-west-1" ? 0 : 1}"
}

resource "aws_route53_record" "pks_api_dns" {
zone_id = "${var.zone_id}"
name = "api.pks.${var.env_name}.${var.dns_suffix}"
Expand All @@ -13,5 +9,5 @@ resource "aws_route53_record" "pks_api_dns" {
evaluate_target_health = true
}

count = "${local.use_route53 ? 1 : 0}"
count = "${var.use_route53}"
}
3 changes: 3 additions & 0 deletions modules/pks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ variable "dns_suffix" {
type = "string"
}

variable "use_route53" {
}

variable "tags" {
type = "map"
}
Expand Down
3 changes: 3 additions & 0 deletions terraforming-control-plane/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module "infra" {

hosted_zone = "${var.hosted_zone}"
dns_suffix = "${var.dns_suffix}"
use_route53 = "${var.use_route53}"

internetless = false
tags = "${local.actual_tags}"
Expand All @@ -59,6 +60,7 @@ module "ops_manager" {
vpc_cidr = "${var.vpc_cidr}"
dns_suffix = "${var.dns_suffix}"
zone_id = "${module.infra.zone_id}"
use_route53 = "${var.use_route53}"

# additional_iam_roles_arn = ["${module.pas.iam_pas_bucket_role_arn}"]
bucket_suffix = "${local.bucket_suffix}"
Expand All @@ -78,6 +80,7 @@ module "control_plane" {
region = "${var.region}"
dns_suffix = "${var.dns_suffix}"
zone_id = "${module.infra.zone_id}"
use_route53 = "${var.use_route53}"
}

module "rds" {
Expand Down
5 changes: 5 additions & 0 deletions terraforming-control-plane/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ variable "hosted_zone" {
default = ""
}

variable "use_route53" {
default = true
description = "Indicate whether or not to enable route53"
}

/**************
* Ops Manager *
***************/
Expand Down
3 changes: 3 additions & 0 deletions terraforming-pas/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module "infra" {

hosted_zone = "${var.hosted_zone}"
dns_suffix = "${var.dns_suffix}"
use_route53 = "${var.use_route53}"

tags = "${local.actual_tags}"
}
Expand All @@ -73,6 +74,7 @@ module "ops_manager" {
vpc_cidr = "${var.vpc_cidr}"
dns_suffix = "${var.dns_suffix}"
zone_id = "${module.infra.zone_id}"
use_route53 = "${var.use_route53}"
additional_iam_roles_arn = ["${module.pas.iam_pas_bucket_role_arn}"]
bucket_suffix = "${local.bucket_suffix}"

Expand Down Expand Up @@ -121,6 +123,7 @@ module "pas" {
bucket_suffix = "${local.bucket_suffix}"
zone_id = "${module.infra.zone_id}"
dns_suffix = "${var.dns_suffix}"
use_route53 = "${var.use_route53}"

create_backup_pas_buckets = "${var.create_backup_pas_buckets}"
create_versioned_pas_buckets = "${var.create_versioned_pas_buckets}"
Expand Down
5 changes: 5 additions & 0 deletions terraforming-pas/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ variable "vpc_cidr" {
default = "10.0.0.0/16"
}

variable "use_route53" {
default = true
description = "Indicate whether or not to enable route53"
}

/******
* PAS *
*******/
Expand Down
7 changes: 5 additions & 2 deletions terraforming-pks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module "infra" {

hosted_zone = "${var.hosted_zone}"
dns_suffix = "${var.dns_suffix}"
use_route53 = "${var.use_route53}"

tags = "${local.actual_tags}"
}
Expand All @@ -72,6 +73,7 @@ module "ops_manager" {
vpc_cidr = "${var.vpc_cidr}"
dns_suffix = "${var.dns_suffix}"
zone_id = "${module.infra.zone_id}"
use_route53 = "${var.use_route53}"
bucket_suffix = "${local.bucket_suffix}"
additional_iam_roles_arn = ["${module.pks.pks_worker_iam_role_arn}", "${module.pks.pks_master_iam_role_arn}"]

Expand Down Expand Up @@ -102,8 +104,9 @@ module "pks" {
private_route_table_ids = "${module.infra.deployment_route_table_ids}"
public_subnet_ids = "${module.infra.public_subnet_ids}"

zone_id = "${module.infra.zone_id}"
dns_suffix = "${var.dns_suffix}"
zone_id = "${module.infra.zone_id}"
dns_suffix = "${var.dns_suffix}"
use_route53 = "${var.use_route53}"

tags = "${local.actual_tags}"
}
Expand Down
5 changes: 5 additions & 0 deletions terraforming-pks/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ variable "vpc_cidr" {
default = "10.0.0.0/16"
}

variable "use_route53" {
default = true
description = "Indicate whether or not to enable route53"
}

/****************
* Ops Manager *
*****************/
Expand Down

0 comments on commit 9a47766

Please sign in to comment.