Skip to content
This repository was archived by the owner on Feb 5, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 8 additions & 25 deletions modules/dns/route53/tectonic.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,13 @@ data "aws_route53_zone" "tectonic" {
}

locals {
private_zone_id = "${var.tectonic_external_private_zone == "" ?
join("", aws_route53_zone.tectonic_int.*.zone_id) :
var.tectonic_external_private_zone}"

public_zone_id = "${join("", data.aws_route53_zone.tectonic.*.zone_id)}"

zone_id = "${var.tectonic_private_endpoints ?
local.private_zone_id :
zone_id = "${var.private_endpoints ?
var.private_zone_id :
local.public_zone_id}"
}

resource "aws_route53_zone" "tectonic_int" {
count = "0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this resource was never used :/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean we're not doing split horizon anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we still have split horizon, it was just moved somewhere else and this was never cleaned up: https://github.com/coreos/tectonic-installer/blob/master/steps/topology/aws/main.tf#L22

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Makes sense then. All cool!

vpc_id = "${var.tectonic_external_vpc_id}"
name = "${var.base_domain}"
force_destroy = true

tags = "${merge(map(
"Name", "${var.cluster_name}_tectonic_int_zone",
"KubernetesCluster", "${var.cluster_name}",
"tectonicClusterID", "${var.cluster_id}"
), var.tectonic_extra_tags)}"
}

resource "aws_route53_record" "tectonic_api" {
count = "${var.elb_alias_enabled ? 0 : 1}"
zone_id = "${local.public_zone_id}"
Expand All @@ -37,7 +20,7 @@ resource "aws_route53_record" "tectonic_api" {
}

resource "aws_route53_record" "tectonic_api_external" {
count = "${var.elb_alias_enabled ? var.tectonic_public_endpoints : 0}"
count = "${var.elb_alias_enabled ? var.public_endpoints : 0}"
zone_id = "${local.public_zone_id}"
name = "${var.cluster_name}-api.${var.base_domain}"
type = "A"
Expand All @@ -50,8 +33,8 @@ resource "aws_route53_record" "tectonic_api_external" {
}

resource "aws_route53_record" "tectonic_api_internal" {
count = "${var.elb_alias_enabled ? var.tectonic_private_endpoints : 0}"
zone_id = "${local.private_zone_id}"
count = "${var.elb_alias_enabled ? var.private_endpoints : 0}"
zone_id = "${var.private_zone_id}"
name = "${var.cluster_name}-api.${var.base_domain}"
type = "A"

Expand All @@ -72,7 +55,7 @@ resource "aws_route53_record" "tectonic-console" {
}

resource "aws_route53_record" "tectonic_ingress_public" {
count = "${var.elb_alias_enabled ? var.tectonic_public_endpoints : 0}"
count = "${var.elb_alias_enabled ? var.public_endpoints : 0}"
zone_id = "${local.public_zone_id}"
name = "${var.cluster_name}.${var.base_domain}"
type = "A"
Expand All @@ -85,8 +68,8 @@ resource "aws_route53_record" "tectonic_ingress_public" {
}

resource "aws_route53_record" "tectonic_ingress_private" {
count = "${var.elb_alias_enabled ? var.tectonic_private_endpoints : 0}"
zone_id = "${local.private_zone_id}"
count = "${var.elb_alias_enabled ? var.private_endpoints : 0}"
zone_id = "${var.private_zone_id}"
name = "${var.cluster_name}.${var.base_domain}"
type = "A"

Expand Down
19 changes: 7 additions & 12 deletions modules/dns/route53/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ variable "api_ip_addresses" {
type = "list"
}

variable "tectonic_extra_tags" {
variable "extra_tags" {
type = "map"
description = "(optional) Extra tags to be applied to created resources."
}
Expand All @@ -70,7 +70,7 @@ EOF
default = false
}

variable "tectonic_external_vpc_id" {
variable "external_vpc_id" {
type = "string"

description = <<EOF
Expand All @@ -81,28 +81,23 @@ Example: `vpc-123456`
EOF
}

variable "tectonic_private_endpoints" {
variable "private_endpoints" {
description = <<EOF
(optional) If set to true, create private-facing ingress resources (ELB, A-records).
If set to false, no private-facing ingress resources will be provisioned and all DNS records will be created in the public Route53 zone.
EOF
}

variable "tectonic_public_endpoints" {
variable "public_endpoints" {
description = <<EOF
(optional) If set to true, create public-facing ingress resources (ELB, A-records).
If set to false, no public-facing ingress resources will be created.
EOF
}

variable "tectonic_external_private_zone" {
description = <<EOF
(optional) If set, the given Route53 zone ID will be used as the internal (private) zone.
This zone will be used to create etcd DNS records as well as internal API and internal Ingress records.
If set, no additional private zone will be created.

# Example: `"Z1ILINNUJGTAO1"`
EOF
variable "private_zone_id" {
description = "Route53 Private Zone ID"
type = "string"
}

variable "api_external_elb_dns_name" {
Expand Down
2 changes: 1 addition & 1 deletion steps/etcd/aws/inputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ locals {
sg_id = "${data.terraform_remote_state.topology.etcd_sg_id}"
subnet_ids_workers = "${data.terraform_remote_state.topology.subnet_ids_workers}"
s3_bucket = "${data.terraform_remote_state.topology.s3_bucket}"
private_zone_id = "${data.terraform_remote_state.topology.private_zone_id}"
private_zone_id = "${var.tectonic_aws_external_private_zone != "" ? var.tectonic_aws_external_private_zone : data.terraform_remote_state.topology.private_zone_id}"
}
2 changes: 1 addition & 1 deletion steps/tnc_dns/aws/inputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ data "terraform_remote_state" "topology" {
}

locals {
private_zone_id = "${data.terraform_remote_state.topology.private_zone_id}"
private_zone_id = "${var.tectonic_aws_external_private_zone != "" ? var.tectonic_aws_external_private_zone : data.terraform_remote_state.topology.private_zone_id}"
tnc_s3_bucket_domain_name = "${data.terraform_remote_state.topology.tnc_s3_bucket_domain_name}"
tnc_elb_dns_name = "${data.terraform_remote_state.topology.tnc_elb_dns_name}"
tnc_elb_zone_id = "${data.terraform_remote_state.topology.tnc_elb_zone_id}"
Expand Down
35 changes: 18 additions & 17 deletions steps/topology/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module "container_linux" {

# TNC
resource "aws_route53_zone" "tectonic_int" {
count = "${var.tectonic_aws_private_endpoints ? "${var.tectonic_aws_external_private_zone == "" ? 1 : 0 }" : 0}"
vpc_id = "${module.vpc.vpc_id}"
name = "${var.tectonic_base_domain}"
force_destroy = true
Expand Down Expand Up @@ -56,21 +57,21 @@ module "vpc" {
module "dns" {
source = "../../../modules/dns/route53"

api_external_elb_dns_name = "${module.vpc.aws_api_external_dns_name}"
api_external_elb_zone_id = "${module.vpc.aws_elb_api_external_zone_id}"
api_internal_elb_dns_name = "${module.vpc.aws_api_internal_dns_name}"
api_internal_elb_zone_id = "${module.vpc.aws_elb_api_internal_zone_id}"
api_ip_addresses = "${module.vpc.aws_lbs}"
base_domain = "${var.tectonic_base_domain}"
cluster_id = "${var.tectonic_cluster_id}"
cluster_name = "${var.tectonic_cluster_name}"
console_elb_dns_name = "${module.vpc.aws_console_dns_name}"
console_elb_zone_id = "${module.vpc.aws_elb_console_zone_id}"
elb_alias_enabled = true
master_count = "${var.tectonic_master_count}"
tectonic_external_private_zone = "${join("", aws_route53_zone.tectonic_int.*.zone_id)}"
tectonic_external_vpc_id = "${module.vpc.vpc_id}"
tectonic_extra_tags = "${var.tectonic_aws_extra_tags}"
tectonic_private_endpoints = "${var.tectonic_aws_private_endpoints}"
tectonic_public_endpoints = "${var.tectonic_aws_public_endpoints}"
api_external_elb_dns_name = "${module.vpc.aws_api_external_dns_name}"
api_external_elb_zone_id = "${module.vpc.aws_elb_api_external_zone_id}"
api_internal_elb_dns_name = "${module.vpc.aws_api_internal_dns_name}"
api_internal_elb_zone_id = "${module.vpc.aws_elb_api_internal_zone_id}"
api_ip_addresses = "${module.vpc.aws_lbs}"
base_domain = "${var.tectonic_base_domain}"
cluster_id = "${var.tectonic_cluster_id}"
cluster_name = "${var.tectonic_cluster_name}"
console_elb_dns_name = "${module.vpc.aws_console_dns_name}"
console_elb_zone_id = "${module.vpc.aws_elb_console_zone_id}"
elb_alias_enabled = true
master_count = "${var.tectonic_master_count}"
private_zone_id = "${var.tectonic_aws_external_private_zone != "" ? var.tectonic_aws_external_private_zone : join("", aws_route53_zone.tectonic_int.*.zone_id)}"
external_vpc_id = "${module.vpc.vpc_id}"
extra_tags = "${var.tectonic_aws_extra_tags}"
private_endpoints = "${var.tectonic_aws_private_endpoints}"
public_endpoints = "${var.tectonic_aws_public_endpoints}"
}
2 changes: 1 addition & 1 deletion steps/topology/aws/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ output "worker_sg_id" {

# TNC
output "private_zone_id" {
value = "${aws_route53_zone.tectonic_int.id}"
value = "${join("", aws_route53_zone.tectonic_int.*.zone_id)}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if you considered to use a ternary here to return either tectonic_aws_external_private_zone or aws_route53_zone.tectonic_int.*.zone_id then it would be transparent for consumers steps, so the private_zone_id input wouldn't need to do the check and could keep just private_zone_id = "${data.terraform_remote_state.topology.private_zone_id}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I did, but I decided against it for consistency and clarity. Otherwise, I foresee a near future where someone forgets that this variable is already the result of a ternary and adds another ternary on top. It wouldn't hurt the output but it is muddy.

}

output "tnc_elb_dns_name" {
Expand Down