Skip to content

Commit

Permalink
module/dns: aws now uses the route53 module
Browse files Browse the repository at this point in the history
  • Loading branch information
Karen Almog committed Nov 1, 2017
1 parent b5685cb commit ec2cfa5
Show file tree
Hide file tree
Showing 21 changed files with 364 additions and 215 deletions.
8 changes: 0 additions & 8 deletions modules/aws/etcd/dns.tf

This file was deleted.

5 changes: 2 additions & 3 deletions modules/aws/etcd/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# We have to do this join() & split() 'trick' because the ternary operator can't output lists.
output "endpoints" {
value = ["${split(",", length(var.external_endpoints) == 0 ? join(",", aws_route53_record.etc_a_nodes.*.fqdn) : join(",", var.external_endpoints))}"]
output "ip_addresses" {
value = "${aws_instance.etcd_node.*.private_ip}"
}
10 changes: 0 additions & 10 deletions modules/aws/etcd/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ variable "container_linux_version" {
type = "string"
}

variable "dns_zone_id" {
type = "string"
}

variable "instance_count" {
default = "3"
}
Expand Down Expand Up @@ -73,12 +69,6 @@ variable "sg_ids" {
description = "The security group IDs to be applied."
}

variable "dns_enabled" {
description = "If set to true, DNS records for etcd nodes will be created."
type = "string"
default = "false"
}

variable "tls_enabled" {
default = false
}
Expand Down
2 changes: 1 addition & 1 deletion modules/aws/master-asg/master.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ resource "aws_autoscaling_group" "masters" {
launch_configuration = "${aws_launch_configuration.master_conf.id}"
vpc_zone_identifier = ["${var.subnet_ids}"]

load_balancers = ["${compact(concat(aws_elb.api_internal.*.id, list(aws_elb.console.id), aws_elb.api_external.*.id))}"]
load_balancers = ["${var.aws_lbs}"]

tags = [
{
Expand Down
15 changes: 0 additions & 15 deletions modules/aws/master-asg/outputs.tf

This file was deleted.

37 changes: 6 additions & 31 deletions modules/aws/master-asg/variables.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
variable "api_sg_ids" {
type = "list"
description = "The security group IDs to be applied to the public facing ELB."
}

variable "assets_s3_location" {
type = "string"
description = "Location on S3 of the Bootkube/Tectonic assets to use (bucket/key)"
Expand Down Expand Up @@ -35,31 +30,15 @@ variable "cluster_name" {
type = "string"
}

variable "console_sg_ids" {
type = "list"
description = "The security group IDs to be applied to the console ELB."
}

variable "container_images" {
description = "Container images to use"
type = "map"
}

variable "custom_dns_name" {
type = "string"
default = ""
description = "DNS prefix used to construct the console and API server endpoints."
}

variable "ec2_type" {
type = "string"
}

variable "external_zone_id" {
type = "string"
description = "ID of the public facing Route53 Hosted Zone on which the ELB records will be created"
}

variable "extra_tags" {
description = "Extra AWS tags to be applied to created resources."
type = "map"
Expand All @@ -79,11 +58,6 @@ variable "instance_count" {
type = "string"
}

variable "internal_zone_id" {
type = "string"
description = "ID of the internal facing Route53 Hosted Zone on which the ELB records will be created"
}

variable "master_iam_role" {
type = "string"
default = ""
Expand All @@ -95,16 +69,17 @@ variable "master_sg_ids" {
description = "The security group IDs to be applied to the master nodes."
}

variable "private_endpoints" {
description = "If set to true, private-facing ingress resources are created."
default = true
}

variable "public_endpoints" {
description = "If set to true, public-facing ingress resources are created."
default = true
}

variable "aws_lbs" {
description = "List of aws_lb IDs for the Console & APIs"
type = "list"
default = []
}

variable "root_volume_iops" {
type = "string"
default = "100"
Expand Down
70 changes: 9 additions & 61 deletions modules/aws/master-asg/elb.tf → modules/aws/vpc/master-elb.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "aws_elb" "api_internal" {
count = "${var.private_endpoints}"
count = "${var.private_master_endpoints}"
name = "${var.cluster_name}-int"
subnets = ["${var.subnet_ids}"]
subnets = ["${local.master_subnet_ids}"]
internal = true
security_groups = ["${var.api_sg_ids}"]
security_groups = ["${aws_security_group.api.id}"]

idle_timeout = 3600
connection_draining = true
Expand Down Expand Up @@ -31,25 +31,12 @@ resource "aws_elb" "api_internal" {
), var.extra_tags)}"
}

resource "aws_route53_record" "api_internal" {
count = "${var.private_endpoints}"
zone_id = "${var.internal_zone_id}"
name = "${var.custom_dns_name == "" ? var.cluster_name : var.custom_dns_name}-api.${var.base_domain}"
type = "A"

alias {
name = "${aws_elb.api_internal.dns_name}"
zone_id = "${aws_elb.api_internal.zone_id}"
evaluate_target_health = true
}
}

resource "aws_elb" "api_external" {
count = "${var.public_endpoints}"
count = "${var.public_master_endpoints}"
name = "${var.custom_dns_name == "" ? var.cluster_name : var.custom_dns_name}-ext"
subnets = ["${var.subnet_ids}"]
subnets = ["${local.master_subnet_ids}"]
internal = false
security_groups = ["${var.api_sg_ids}"]
security_groups = ["${aws_security_group.api.id}"]

idle_timeout = 3600
connection_draining = true
Expand Down Expand Up @@ -77,24 +64,11 @@ resource "aws_elb" "api_external" {
), var.extra_tags)}"
}

resource "aws_route53_record" "api_external" {
count = "${var.public_endpoints}"
zone_id = "${var.external_zone_id}"
name = "${var.custom_dns_name == "" ? var.cluster_name : var.custom_dns_name}-api.${var.base_domain}"
type = "A"

alias {
name = "${aws_elb.api_external.dns_name}"
zone_id = "${aws_elb.api_external.zone_id}"
evaluate_target_health = true
}
}

resource "aws_elb" "console" {
name = "${var.custom_dns_name == "" ? var.cluster_name : var.custom_dns_name}-con"
subnets = ["${var.subnet_ids}"]
internal = "${var.public_endpoints ? false : true}"
security_groups = ["${var.console_sg_ids}"]
subnets = ["${local.master_subnet_ids}"]
internal = "${var.public_master_endpoints ? false : true}"
security_groups = ["${aws_security_group.console.id}"]

idle_timeout = 3600

Expand Down Expand Up @@ -126,29 +100,3 @@ resource "aws_elb" "console" {
"tectonicClusterID", "${var.cluster_id}"
), var.extra_tags)}"
}

resource "aws_route53_record" "ingress_public" {
count = "${var.public_endpoints}"
zone_id = "${var.external_zone_id}"
name = "${var.custom_dns_name == "" ? var.cluster_name : var.custom_dns_name}.${var.base_domain}"
type = "A"

alias {
name = "${aws_elb.console.dns_name}"
zone_id = "${aws_elb.console.zone_id}"
evaluate_target_health = true
}
}

resource "aws_route53_record" "ingress_private" {
count = "${var.private_endpoints}"
zone_id = "${var.internal_zone_id}"
name = "${var.custom_dns_name == "" ? var.cluster_name : var.custom_dns_name}.${var.base_domain}"
type = "A"

alias {
name = "${aws_elb.console.dns_name}"
zone_id = "${aws_elb.console.zone_id}"
evaluate_target_health = true
}
}
44 changes: 42 additions & 2 deletions modules/aws/vpc/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ output "vpc_id" {
# We have to do this join() & split() 'trick' because null_data_source and
# the ternary operator can't output lists or maps
output "master_subnet_ids" {
value = ["${split(",", var.external_vpc_id == "" ? join(",", aws_subnet.master_subnet.*.id) : join(",", data.aws_subnet.external_master.*.id))}"]
value = "${local.master_subnet_ids}"
}

output "worker_subnet_ids" {
value = ["${split(",", var.external_vpc_id == "" ? join(",", aws_subnet.worker_subnet.*.id) : join(",", data.aws_subnet.external_worker.*.id))}"]
value = "${local.worker_subnet_ids}"
}

output "etcd_sg_id" {
Expand All @@ -31,3 +31,43 @@ output "api_sg_id" {
output "console_sg_id" {
value = "${aws_security_group.console.id}"
}

output "aws_elb_api_external_id" {
value = "${aws_elb.api_external.*.id}"
}

output "aws_elb_internal_id" {
value = "${aws_elb.api_internal.*.id}"
}

output "aws_elb_console_id" {
value = "${aws_elb.console.id}"
}

output "aws_lbs" {
value = ["${compact(concat(aws_elb.api_internal.*.id, list(aws_elb.console.id), aws_elb.api_external.*.id))}"]
}

output "aws_api_external_dns_name" {
value = "${aws_elb.api_external.dns_name}"
}

output "aws_elb_api_external_zone_id" {
value = "${aws_elb.api_external.zone_id}"
}

output "aws_api_internal_dns_name" {
value = "${aws_elb.api_internal.dns_name}"
}

output "aws_elb_api_internal_zone_id" {
value = "${aws_elb.api_internal.zone_id}"
}

output "aws_console_dns_name" {
value = "${aws_elb.console.dns_name}"
}

output "aws_elb_onsole_zone_id" {
value = "${aws_elb.console.zone_id}"
}
16 changes: 16 additions & 0 deletions modules/aws/vpc/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,19 @@ variable "master_azs" {
variable "worker_azs" {
type = "list"
}

variable "private_master_endpoints" {
description = "If set to true, private-facing ingress resources are created."
default = true
}

variable "public_master_endpoints" {
description = "If set to true, public-facing ingress resources are created."
default = true
}

variable "custom_dns_name" {
type = "string"
default = ""
description = "DNS prefix used to construct the console and API server endpoints."
}
5 changes: 5 additions & 0 deletions modules/aws/vpc/vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ data "aws_vpc" "cluster_vpc" {
#
id = "${var.external_vpc_id == "" ? join(" ", aws_vpc.new_vpc.*.id) : var.external_vpc_id }"
}

locals {
master_subnet_ids = ["${split(",", var.external_vpc_id == "" ? join(",", aws_subnet.master_subnet.*.id) : join(",", data.aws_subnet.external_master.*.id))}"]
worker_subnet_ids = ["${split(",", var.external_vpc_id == "" ? join(",", aws_subnet.worker_subnet.*.id) : join(",", data.aws_subnet.external_worker.*.id))}"]
}
2 changes: 1 addition & 1 deletion modules/dns/route53/etcd.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resource "aws_route53_record" "etcd_a_nodes" {
count = "${var.self_hosted_etcd != "" ? 0 : var.etcd_count}"
type = "A"
ttl = "60"
zone_id = "${data.aws_route53_zone.tectonic.zone_id}"
zone_id = "${local.zone_id}"
name = "${var.cluster_name}-etcd-${count.index}"
records = ["${var.etcd_ips[count.index]}"]
}
2 changes: 1 addition & 1 deletion modules/dns/route53/master.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "aws_route53_record" "master_nodes" {
count = "${var.master_count}"
count = "${var.elb_alias_enabled ? 0 : var.master_count}"
zone_id = "${data.aws_route53_zone.tectonic.zone_id}"
name = "${var.cluster_name}-master-${count.index}"
type = "A"
Expand Down
21 changes: 21 additions & 0 deletions modules/dns/route53/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ output "etcd_a_nodes" {
value = "${aws_route53_record.etcd_a_nodes.*.fqdn}"
}

# We have to do this join() & split() 'trick' because the ternary operator can't output lists.
output "etcd_endpoints" {
value = ["${split(",", length(var.external_endpoints) == 0 ? join(",", aws_route53_record.etcd_a_nodes.*.fqdn) : join(",", var.external_endpoints))}"]
}

output "worker_nodes" {
value = "${aws_route53_record.worker_nodes.*.fqdn}"
}
Expand All @@ -13,3 +18,19 @@ output "worker_nodes_public" {
output "master_nodes" {
value = "${aws_route53_record.master_nodes.*.fqdn}"
}

output "ingress_external_fqdn" {
value = "${join(" ", aws_route53_record.tectonic_ingress_public.*.name)}"
}

output "ingress_internal_fqdn" {
value = "${join(" ", aws_route53_record.tectonic_ingress_private.*.name)}"
}

output "api_external_fqdn" {
value = "${join(" ", aws_route53_record.tectonic_api_external.*.name)}"
}

output "api_internal_fqdn" {
value = "${join(" ", aws_route53_record.tectonic_api_internal.*.name)}"
}
Loading

0 comments on commit ec2cfa5

Please sign in to comment.