Skip to content

feat: Added support for private hosted zone in Route53 #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

agustin58ruiz
Copy link

@agustin58ruiz agustin58ruiz commented May 17, 2025

Description

main.tf
before:
data "aws_route53_zone" "this" {
count = local.create_domain_name && var.create_domain_records ? 1 : 0

name = coalesce(var.hosted_zone_name, local.stripped_domain_name)
}
now:
data "aws_route53_zone" "this" {
count = local.create_domain_name && var.create_domain_records ? 1 : 0
private_zone = var.private_zone
name = coalesce(var.hosted_zone_name, local.stripped_domain_name)
}

variables.tf
added:

line 159: variable "private_zone" {
description = "Whether the hosted zone is private or not"
type = bool
default = false
}

Motivation and Context

This is needed when someone wants to create records in a private hosted zone. The private_zone argument is required when looking up private zones using the aws_route53_zone data source. Without this parameter, Terraform cannot find the private zone, even if the zone name matches.

Breaking Changes

This change introduces a new variable (private_zone) with a default value of false, so it is backward compatible.

However, users must explicitly set private_zone = true when creating records in a private hosted zone. Failing to do so will result in the zone not being found.

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

@agustin58ruiz
Copy link
Author

I need this change for my work. I need the domain name to be created in a private zone.

@antonbabenko antonbabenko changed the title Fix. Now module can find between private hosted zone. Added private_zone bool variable. feat: Added support for private hosted zone in Route53 May 17, 2025
@antonbabenko
Copy link
Member

Looks good, please run pre-commit run -a on your PR and let's merge it.

@agustin58ruiz
Copy link
Author

Hello!
I hope you're faring well.
I run pre-commit run -a and worked successfully.
Regards

@antonbabenko
Copy link
Member

Please fix the failing checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants