Skip to content

Commit

Permalink
add route53 endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
morga471 committed Jul 30, 2024
1 parent a98436a commit c9d2fa5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 43 deletions.
40 changes: 13 additions & 27 deletions dns-zone-cat.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
locals {
cluster_domain_name = format("%v.%v", var.cluster_name, var.domain)
cluster_domain_name = format("%v.%v", var.cluster_name, var.vpc_domain_name)
cluster_domain_description = format("%v EKS Cluster DNS Zone", var.cluster_name)
# true for gov, false for cat
aws_dns_infrastructure = false
region = data.aws_region.current.name
}

resource "aws_route53_zone" "cluster_domain" {
Expand All @@ -16,28 +15,15 @@ resource "aws_route53_zone" "cluster_domain" {
vpc_region = local.region
}

## dynamic "vpc" {
## for_each = true ? var.region_map : {}
## iterator = r
## content {
## vpc_id = var.main_dns_vpcs[r.value]
## vpc_region = r.value
## }
## }

lifecycle {
ignore_changes = [vpc]
}

tags = merge(
local.base_tags,
# local.common_tags,
var.tags,
# var.application_tags,
tomap({ "Name" = local.cluster_domain_name }),
)

# depends_on = [ aws_route53_vpc_association_authorization.west_cluster_domain, aws_route53_vpc_association_authorization.east_cluster_domain ]
}

output "cluster_domain_name" {
Expand All @@ -56,20 +42,20 @@ output "cluster_domain_ns" {
}

# now we need to add the NS records for the new zone to the parent zone
# data "aws_route53_zone" "parent" {
# name = var.domain
# private_zone = true
# }
data "aws_route53_zone" "parent" {
name = var.vpc_domain_name
private_zone = true
}

# resource "aws_route53_record" "cluster_domain" {
# allow_overwrite = true
# name = local.cluster_domain_name
# type = "NS"
# ttl = 900
# zone_id = data.aws_route53_zone.parent.zone_id
resource "aws_route53_record" "cluster_domain" {
allow_overwrite = true
name = local.cluster_domain_name
type = "NS"
ttl = 900
zone_id = data.aws_route53_zone.parent.zone_id

# records = aws_route53_zone.cluster_domain.name_servers
# }
records = aws_route53_zone.cluster_domain.name_servers
}

## #---
## # associate to main do2-govcloud vpc1-services east and west for inbound resolution
Expand Down
28 changes: 12 additions & 16 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,15 @@ variable "region_map" {
default = {"east": "us-gov-east-1", "west": "us-gov-west-1"}
}

# variable "route53_endpoints" {
# description = "Map of target route53 endpoints (for inbound) central VPCs"
# type = map(map(string))
# default = {
# route53_main = {
# "account_id" = "057405694017"
# "us-gov-east-1" = "vpc-0871ba8a6040d623a"
# "us-gov-west-1" = "vpc-0f03ea065333f72c5"
# }
# route53_main_legacy = {
# "account_id" = "107742151971"
# "us-gov-east-1" = "vpc-099a991da7c4eb8a5"
# "us-gov-west-1" = "vpc-77877a12"
# }
# }
# }
variable "route53_endpoints" {
description = "Map of target route53 endpoints (for inbound) central VPCs"
type = map(map(string))
default = {
route53_main = {
"account_id" = "269244441389"
"alias" = "lab-gov-network-nonprod"
"us-gov-east-1" = "vpc-070595c5b133243dd"
"us-gov-west-1" = "vpc-08b7b4db6a5ddf9c1"
}
}
}

0 comments on commit c9d2fa5

Please sign in to comment.