feat: Added support for private hosted zone in Route53 #136
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?
examples/*
to demonstrate and validate my change(s)examples/*
projectspre-commit run -a
on my pull request