Skip to content

Commit 52fa251

Browse files
feat: Support option of private hosted zone for Route53 records (#137)
Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
1 parent 7a5b880 commit 52fa251

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ module "api_gateway" {
229229
| <a name="input_body"></a> [body](#input\_body) | An OpenAPI specification that defines the set of routes and integrations to create as part of the HTTP APIs. Supported only for HTTP APIs | `string` | `null` | no |
230230
| <a name="input_cors_configuration"></a> [cors\_configuration](#input\_cors\_configuration) | The cross-origin resource sharing (CORS) configuration. Applicable for HTTP APIs | <pre>object({<br/> allow_credentials = optional(bool)<br/> allow_headers = optional(list(string))<br/> allow_methods = optional(list(string))<br/> allow_origins = optional(list(string))<br/> expose_headers = optional(list(string), [])<br/> max_age = optional(number)<br/> })</pre> | `null` | no |
231231
| <a name="input_create"></a> [create](#input\_create) | Controls if resources should be created | `bool` | `true` | no |
232-
| <a name="input_create_certificate"></a> [create\_certificate](#input\_create\_certificate) | Whether to create a certificate for the domain | `bool` | `true` | no |
232+
| <a name="input_create_certificate"></a> [create\_certificate](#input\_create\_certificate) | Whether to create a certificate for the domain. Since certificate validate only works on public domains, this will be ignore if `private_zone` is set to `true` | `bool` | `true` | no |
233233
| <a name="input_create_domain_name"></a> [create\_domain\_name](#input\_create\_domain\_name) | Whether to create API domain name resource | `bool` | `true` | no |
234234
| <a name="input_create_domain_records"></a> [create\_domain\_records](#input\_create\_domain\_records) | Whether to create Route53 records for the domain name | `bool` | `true` | no |
235235
| <a name="input_create_routes_and_integrations"></a> [create\_routes\_and\_integrations](#input\_create\_routes\_and\_integrations) | Whether to create routes and integrations resources | `bool` | `true` | no |
@@ -246,6 +246,7 @@ module "api_gateway" {
246246
| <a name="input_ip_address_type"></a> [ip\_address\_type](#input\_ip\_address\_type) | The IP address types that can invoke the API. Valid values: ipv4, dualstack. Use ipv4 to allow only IPv4 addresses to invoke your API, or use dualstack to allow both IPv4 and IPv6 addresses to invoke your API. Defaults to ipv4. | `string` | `null` | no |
247247
| <a name="input_mutual_tls_authentication"></a> [mutual\_tls\_authentication](#input\_mutual\_tls\_authentication) | The mutual TLS authentication configuration for the domain name | `map(string)` | `{}` | no |
248248
| <a name="input_name"></a> [name](#input\_name) | The name of the API. Must be less than or equal to 128 characters in length | `string` | `""` | no |
249+
| <a name="input_private_zone"></a> [private\_zone](#input\_private\_zone) | Indicates the hosted zone being looked up is private. Certificate validation will fail if this is set to true. | `bool` | `false` | no |
249250
| <a name="input_protocol_type"></a> [protocol\_type](#input\_protocol\_type) | The API protocol. Valid values: `HTTP`, `WEBSOCKET` | `string` | `"HTTP"` | no |
250251
| <a name="input_route_key"></a> [route\_key](#input\_route\_key) | Part of quick create. Specifies any route key. Applicable for HTTP APIs | `string` | `null` | no |
251252
| <a name="input_route_selection_expression"></a> [route\_selection\_expression](#input\_route\_selection\_expression) | The route selection expression for the API. Defaults to `$request.method $request.path` | `string` | `null` | no |

main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ locals {
136136
data "aws_route53_zone" "this" {
137137
count = local.create_domain_name && var.create_domain_records ? 1 : 0
138138

139-
name = coalesce(var.hosted_zone_name, local.stripped_domain_name)
139+
name = coalesce(var.hosted_zone_name, local.stripped_domain_name)
140+
private_zone = var.private_zone
140141
}
141142

142143
resource "aws_route53_record" "this" {
@@ -158,7 +159,7 @@ resource "aws_route53_record" "this" {
158159
################################################################################
159160

160161
locals {
161-
create_certificate = local.create_domain_name && var.create_certificate
162+
create_certificate = local.create_domain_name && var.create_certificate && !var.private_zone
162163

163164
is_wildcard = startswith(var.domain_name, "*.")
164165
}

variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ variable "hosted_zone_name" {
156156
default = null
157157
}
158158

159+
variable "private_zone" {
160+
description = "Indicates the hosted zone being looked up is private. Certificate validation will fail if this is set to true."
161+
type = bool
162+
default = false
163+
}
164+
159165
variable "domain_name_certificate_arn" {
160166
description = "The ARN of an AWS-managed certificate that will be used by the endpoint for the domain name. AWS Certificate Manager is the only supported source"
161167
type = string
@@ -201,7 +207,7 @@ variable "subdomain_record_types" {
201207
################################################################################
202208

203209
variable "create_certificate" {
204-
description = "Whether to create a certificate for the domain"
210+
description = "Whether to create a certificate for the domain. Since certificate validate only works on public domains, this will be ignore if `private_zone` is set to `true`"
205211
type = bool
206212
default = true
207213
}

wrappers/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module "wrapper" {
2727
ip_address_type = try(each.value.ip_address_type, var.defaults.ip_address_type, null)
2828
mutual_tls_authentication = try(each.value.mutual_tls_authentication, var.defaults.mutual_tls_authentication, {})
2929
name = try(each.value.name, var.defaults.name, "")
30+
private_zone = try(each.value.private_zone, var.defaults.private_zone, false)
3031
protocol_type = try(each.value.protocol_type, var.defaults.protocol_type, "HTTP")
3132
route_key = try(each.value.route_key, var.defaults.route_key, null)
3233
route_selection_expression = try(each.value.route_selection_expression, var.defaults.route_selection_expression, null)

0 commit comments

Comments
 (0)