Skip to content

Commit 57811ba

Browse files
committed
feat(resolver-inbound-endpoint): support latest features for resolver-inbound-endpoint
1 parent ba44b43 commit 57811ba

File tree

8 files changed

+312
-98
lines changed

8 files changed

+312
-98
lines changed

modules/resolver-inbound-endpoint/README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,22 @@ This module creates following resources.
1111

1212
| Name | Version |
1313
|------|---------|
14-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5 |
15-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.27 |
14+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.10 |
15+
| <a name="requirement_assert"></a> [assert](#requirement\_assert) | >= 0.15 |
16+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.72 |
1617

1718
## Providers
1819

1920
| Name | Version |
2021
|------|---------|
21-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.19.0 |
22+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.94.1 |
2223

2324
## Modules
2425

2526
| Name | Source | Version |
2627
|------|--------|---------|
2728
| <a name="module_resource_group"></a> [resource\_group](#module\_resource\_group) | tedilabs/misc/aws//modules/resource-group | ~> 0.10.0 |
28-
| <a name="module_security_group__this"></a> [security\_group\_\_this](#module\_security\_group\_\_this) | tedilabs/network/aws//modules/security-group | ~> 0.26.0 |
29+
| <a name="module_security_group"></a> [security\_group](#module\_security\_group) | tedilabs/network/aws//modules/security-group | ~> 0.32.0 |
2930

3031
## Resources
3132

@@ -38,25 +39,33 @@ This module creates following resources.
3839

3940
| Name | Description | Type | Default | Required |
4041
|------|-------------|------|---------|:--------:|
41-
| <a name="input_ip_allocations"></a> [ip\_allocations](#input\_ip\_allocations) | (Required) A list of IP allocations which include `subnet_id` and `ip`. `ip` is a private IP from `subnet`. | <pre>list(object({<br> subnet_id = string<br> ip = string<br> }))</pre> | n/a | yes |
42+
| <a name="input_ip_allocations"></a> [ip\_allocations](#input\_ip\_allocations) | (Optional) The configuration for IP allocations of the Route53 Resolver Inbound Endpoint. Select at least two Availability Zone and one subnet for each zone. Each item of `ip_allocations` block as defined below.<br/> (Required) `subnet` - The ID of the subnet that contains the IP address. You can specify only one subnet per Availability Zone.<br/> (Optional) `ipv4_address` - IPv4 address from the provided subnet. Defaults to be randomly configured by Amazon.<br/> (Optional) `ipv6_address` - IPv6 address from the provided subnet. Defaults to be randomly configured by Amazon. | <pre>list(object({<br/> subnet = string<br/> ipv4_address = optional(string)<br/> ipv6_address = optional(string)<br/> }))</pre> | n/a | yes |
4243
| <a name="input_name"></a> [name](#input\_name) | (Required) The name of the Route53 Resolver Inbound Endpoint. | `string` | n/a | yes |
43-
| <a name="input_allowed_ingress_cidrs"></a> [allowed\_ingress\_cidrs](#input\_allowed\_ingress\_cidrs) | (Optional) A list of CIDR for Route53 Resolver Inbound Endpoint ingress access. | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
44+
| <a name="input_default_security_group"></a> [default\_security\_group](#input\_default\_security\_group) | (Optional) The configuration of the default security group for the Route53 Resolver Inbound Endpoint. `default_security_group` block as defined below.<br/> (Optional) `enabled` - Whether to use the default security group. Defaults to `true`.<br/> (Optional) `name` - The name of the default security group. If not provided, the Route53 Resolver Inbound Endpoint name is used for the name of security group.<br/> (Optional) `description` - The description of the default security group.<br/> (Optional) `ingress_rules` - A list of ingress rules in a security group. Defaults to `[]`. Each block of `ingress_rules` as defined below.<br/> (Required) `id` - The ID of the ingress rule. This value is only used internally within Terraform code.<br/> (Optional) `description` - The description of the rule.<br/> (Required) `protocol` - The protocol to match. Note that if `protocol` is set to `-1`, it translates to all protocols, all port ranges, and `from_port` and `to_port` values should not be defined.<br/> (Required) `from_port` - The start of port range for the protocols.<br/> (Required) `to_port` - The end of port range for the protocols.<br/> (Optional) `ipv4_cidrs` - The IPv4 network ranges to allow, in CIDR notation.<br/> (Optional) `ipv6_cidrs` - The IPv6 network ranges to allow, in CIDR notation.<br/> (Optional) `prefix_lists` - The prefix list IDs to allow.<br/> (Optional) `security_groups` - The source security group IDs to allow.<br/> (Optional) `self` - Whether the security group itself will be added as a source to this ingress rule.<br/> (Optional) `egress_rules` - A list of egress rules in a security group. Defaults to `[]`. Each block of `egress_rules` as defined below.<br/> (Required) `id` - The ID of the egress rule. This value is only used internally within Terraform code.<br/> (Optional) `description` - The description of the rule.<br/> (Required) `protocol` - The protocol to match. Note that if `protocol` is set to `-1`, it translates to all protocols, all port ranges, and `from_port` and `to_port` values should not be defined.<br/> (Required) `from_port` - The start of port range for the protocols.<br/> (Required) `to_port` - The end of port range for the protocols.<br/> (Optional) `ipv4_cidrs` - The IPv4 network ranges to allow, in CIDR notation.<br/> (Optional) `ipv6_cidrs` - The IPv6 network ranges to allow, in CIDR notation.<br/> (Optional) `prefix_lists` - The prefix list IDs to allow.<br/> (Optional) `security_groups` - The source security group IDs to allow.<br/> (Optional) `self` - Whether the security group itself will be added as a source to this ingress rule.<br/> (Optional) `ingress_ipv4_cidrs` - A list of IPv4 CIDR ranges to allow to query to the endpoint. Defaults to `[]`."<br/> (Optional) `istener_ingress_ipv6_cidrs` - A list of IPv6 CIDR ranges to allow to query to the endpoint. Defaults to `[]`."<br/> (Optional) `ingress_prefix_lists` - A list of prefix list IDs for AWS services to allow to query to the endpoint. Defaults to `[]`."<br/> (Optional) `ingress_security_groups` - A list of security group IDs to allow to query to the endpoint. Defaults to `[]`." | <pre>object({<br/> enabled = optional(bool, true)<br/> name = optional(string)<br/> description = optional(string, "Managed by Terraform.")<br/> ingress_rules = optional(<br/> list(object({<br/> id = string<br/> description = optional(string, "Managed by Terraform.")<br/> protocol = string<br/> from_port = number<br/> to_port = number<br/> ipv4_cidrs = optional(list(string), [])<br/> ipv6_cidrs = optional(list(string), [])<br/> prefix_lists = optional(list(string), [])<br/> security_groups = optional(list(string), [])<br/> self = optional(bool, false)<br/> })),<br/> []<br/> )<br/> egress_rules = optional(<br/> list(object({<br/> id = string<br/> description = optional(string, "Managed by Terraform.")<br/> protocol = string<br/> from_port = number<br/> to_port = number<br/> ipv4_cidrs = optional(list(string), [])<br/> ipv6_cidrs = optional(list(string), [])<br/> prefix_lists = optional(list(string), [])<br/> security_groups = optional(list(string), [])<br/> self = optional(bool, false)<br/> })),<br/> []<br/> )<br/> ingress_ipv4_cidrs = optional(list(string), [])<br/> ingress_ipv6_cidrs = optional(list(string), [])<br/> ingress_prefix_lists = optional(list(string), [])<br/> ingress_security_groups = optional(list(string), [])<br/> })</pre> | `{}` | no |
45+
| <a name="input_ip_address_type"></a> [ip\_address\_type](#input\_ip\_address\_type) | (Optional) The type of IP addresses used by the Route53 Resolver Inbound Endpoint. Valid values are `IPV4`, `IPV6`, `DUALSTACK`. Defaults to `IPV4`. | `string` | `"IPV4"` | no |
4446
| <a name="input_module_tags_enabled"></a> [module\_tags\_enabled](#input\_module\_tags\_enabled) | (Optional) Whether to create AWS Resource Tags for the module informations. | `bool` | `true` | no |
47+
| <a name="input_protocols"></a> [protocols](#input\_protocols) | (Optional) A set of protocols to use for the Route53 Resolver Inbound Endpoint. The protocols determine how data is transmitted to this endpoint. Valid values are `DoH`, `Do53`, or `DoH-FIPS`. Defaults to `["Do53"]`.<br/> `Do53`: DNS over port 53. The data is relayed by using the Route 53 Resolver without additional encryption. While the data cannot be read by external parties, it can be viewed within the AWS networks. Uses either UDP or TCP to send the packets. Do53 is primarily used for traffic within and between Amazon VPCs.<br/> `DoH`: The data is transmitted over an encrypted HTTPS session. DoH adds an added level of security where data can't be decrypted by unauthorized users, and cannot be read by anyone except the intended recipient.<br/> `DoH-FIPS`: The data is transmitted over an encrypted HTTPS session that is compliant with the FIPS 140-2 cryptographic standard. Supported for inbound endpoints only. For more information, see FIPS PUB 140-2 | `set(string)` | <pre>[<br/> "Do53"<br/>]</pre> | no |
4548
| <a name="input_resource_group_description"></a> [resource\_group\_description](#input\_resource\_group\_description) | (Optional) The description of Resource Group. | `string` | `"Managed by Terraform."` | no |
4649
| <a name="input_resource_group_enabled"></a> [resource\_group\_enabled](#input\_resource\_group\_enabled) | (Optional) Whether to create Resource Group to find and group AWS resources which are created by this module. | `bool` | `true` | no |
4750
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | (Optional) The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`. | `string` | `""` | no |
48-
| <a name="input_security_groups"></a> [security\_groups](#input\_security\_groups) | (Optional) A list of security groups for Route53 Resolver Inbound Endpoint. | `list(string)` | `[]` | no |
51+
| <a name="input_security_groups"></a> [security\_groups](#input\_security\_groups) | (Optional) A list of security group IDs to assign to the Route53 Resolver Inbound Endpoint. | `list(string)` | `[]` | no |
4952
| <a name="input_tags"></a> [tags](#input\_tags) | (Optional) A map of tags to add to all resources. | `map(string)` | `{}` | no |
5053

5154
## Outputs
5255

5356
| Name | Description |
5457
|------|-------------|
55-
| <a name="output_arn"></a> [arn](#output\_arn) | The ARN of the Route 53 Resolver Endpoint. |
56-
| <a name="output_id"></a> [id](#output\_id) | The ID of the Route 53 Resolver Endpoint. |
57-
| <a name="output_ip_addresses"></a> [ip\_addresses](#output\_ip\_addresses) | IP addresses in your VPC that you want DNS queries to pass through on the way from your network to your VPCs. |
58-
| <a name="output_name"></a> [name](#output\_name) | The name of the Route 53 Resolver Endpoint. |
59-
| <a name="output_security_group_ids"></a> [security\_group\_ids](#output\_security\_group\_ids) | A list of the ID of security groups that you want to use to control access to this VPC. |
60-
| <a name="output_subnet_ids"></a> [subnet\_ids](#output\_subnet\_ids) | A list of the ID of subnets that IP addresses of resolver endpoint are allocated in. |
58+
| <a name="output_arn"></a> [arn](#output\_arn) | The ARN of the Route53 Resolver Endpoint. |
59+
| <a name="output_default_security_group"></a> [default\_security\_group](#output\_default\_security\_group) | The default security group ID of the Route53 Resolver Endpoint. |
60+
| <a name="output_direction"></a> [direction](#output\_direction) | The direction of DNS queries to or from the Route 53 Resolver endpoint. |
61+
| <a name="output_id"></a> [id](#output\_id) | The ID of the Route53 Resolver Endpoint. |
62+
| <a name="output_ip_address_type"></a> [ip\_address\_type](#output\_ip\_address\_type) | The type of IP addresses used by the Route53 Resolver Inbound Endpoint. |
63+
| <a name="output_ip_allocations"></a> [ip\_allocations](#output\_ip\_allocations) | The configuration for IP allocations of the Route53 Resolver Inbound Endpoint. |
64+
| <a name="output_ipv4_addresses"></a> [ipv4\_addresses](#output\_ipv4\_addresses) | A set of IPv4 addresses in your VPC that you want DNS queries to pass through on the way from your network to your VPCs. |
65+
| <a name="output_ipv6_addresses"></a> [ipv6\_addresses](#output\_ipv6\_addresses) | A set of IPv6 addresses in your VPC that you want DNS queries to pass through on the way from your network to your VPCs. |
66+
| <a name="output_name"></a> [name](#output\_name) | The name of the Route53 Resolver Endpoint. |
67+
| <a name="output_protocols"></a> [protocols](#output\_protocols) | A set of protocols to use for the Route53 Resolver Inbound Endpoint. |
68+
| <a name="output_security_groups"></a> [security\_groups](#output\_security\_groups) | A set of security group IDs which is assigned to the Route53 Resolver Endpoint. |
69+
| <a name="output_subnets"></a> [subnets](#output\_subnets) | A set of the ID of subnets that IP addresses of resolver endpoint are allocated in. |
6170
| <a name="output_vpc_id"></a> [vpc\_id](#output\_vpc\_id) | The ID of the VPC that you want to create the resolver endpoint in. |
6271
<!-- END_TF_DOCS -->

modules/resolver-inbound-endpoint/main.tf

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,26 @@ locals {
1414
} : {}
1515
}
1616

17+
18+
###################################################
19+
# Inbound Endpoint for Route53 Resolver
20+
###################################################
21+
1722
resource "aws_route53_resolver_endpoint" "this" {
18-
name = local.metadata.name
1923
direction = "INBOUND"
24+
name = local.metadata.name
2025

21-
security_group_ids = concat(var.security_groups, [
22-
module.security_group__this.id,
23-
])
26+
protocols = var.protocols
27+
security_group_ids = local.security_groups
2428

29+
resolver_endpoint_type = var.ip_address_type
2530
dynamic "ip_address" {
2631
for_each = var.ip_allocations
2732

2833
content {
29-
subnet_id = ip_address.value.subnet_id
30-
ip = ip_address.value.ip
34+
subnet_id = ip_address.value.subnet
35+
ip = ip_address.value.ipv4_address
36+
ipv6 = ip_address.value.ipv6_address
3137
}
3238
}
3339

@@ -39,51 +45,3 @@ resource "aws_route53_resolver_endpoint" "this" {
3945
var.tags,
4046
)
4147
}
42-
43-
44-
###################################################
45-
# Security Group
46-
###################################################
47-
48-
data "aws_subnet" "this" {
49-
id = var.ip_allocations[0].subnet_id
50-
}
51-
52-
module "security_group__this" {
53-
source = "tedilabs/network/aws//modules/security-group"
54-
version = "~> 0.26.0"
55-
56-
name = local.metadata.name
57-
description = "Security Group for Route53 Resolver Inbound Endpoint."
58-
vpc_id = data.aws_subnet.this.vpc_id
59-
60-
ingress_rules = [
61-
{
62-
id = "dns-tcp/cidrs"
63-
description = "Allow CIDRs to query to Route53 Resolver Inbound Endpoint."
64-
protocol = "tcp"
65-
from_port = 53
66-
to_port = 53
67-
68-
cidr_blocks = var.allowed_ingress_cidrs
69-
},
70-
{
71-
id = "dns-udp/cidrs"
72-
description = "Allow CIDRs to query to Route53 Resolver Inbound Endpoint."
73-
protocol = "udp"
74-
from_port = 53
75-
to_port = 53
76-
77-
cidr_blocks = var.allowed_ingress_cidrs
78-
},
79-
]
80-
egress_rules = []
81-
82-
resource_group_enabled = false
83-
module_tags_enabled = false
84-
85-
tags = merge(
86-
local.module_tags,
87-
var.tags,
88-
)
89-
}
Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,81 @@
11
output "id" {
2-
description = "The ID of the Route 53 Resolver Endpoint."
2+
description = "The ID of the Route53 Resolver Endpoint."
33
value = aws_route53_resolver_endpoint.this.id
44
}
55

66
output "arn" {
7-
description = "The ARN of the Route 53 Resolver Endpoint."
7+
description = "The ARN of the Route53 Resolver Endpoint."
88
value = aws_route53_resolver_endpoint.this.arn
99
}
1010

1111
output "name" {
12-
description = "The name of the Route 53 Resolver Endpoint."
12+
description = "The name of the Route53 Resolver Endpoint."
1313
value = aws_route53_resolver_endpoint.this.name
1414
}
1515

16+
output "direction" {
17+
description = "The direction of DNS queries to or from the Route 53 Resolver endpoint."
18+
value = aws_route53_resolver_endpoint.this.direction
19+
}
20+
21+
output "protocols" {
22+
description = "A set of protocols to use for the Route53 Resolver Inbound Endpoint."
23+
value = aws_route53_resolver_endpoint.this.protocols
24+
}
25+
1626
output "vpc_id" {
1727
description = "The ID of the VPC that you want to create the resolver endpoint in."
1828
value = aws_route53_resolver_endpoint.this.host_vpc_id
1929
}
2030

21-
output "ip_addresses" {
22-
description = "IP addresses in your VPC that you want DNS queries to pass through on the way from your network to your VPCs."
23-
value = aws_route53_resolver_endpoint.this.ip_address[*].ip
31+
output "ip_address_type" {
32+
description = "The type of IP addresses used by the Route53 Resolver Inbound Endpoint."
33+
value = aws_route53_resolver_endpoint.this.resolver_endpoint_type
2434
}
2535

26-
output "security_group_ids" {
27-
description = "A list of the ID of security groups that you want to use to control access to this VPC."
36+
output "ip_allocations" {
37+
description = "The configuration for IP allocations of the Route53 Resolver Inbound Endpoint."
38+
value = {
39+
for ip_allocation in aws_route53_resolver_endpoint.this.ip_address :
40+
data.aws_subnet.this[ip_allocation.subnet_id].availability_zone_id => {
41+
az_id = data.aws_subnet.this[ip_allocation.subnet_id].availability_zone_id
42+
subnet = ip_allocation.subnet_id
43+
id = ip_allocation.ip_id
44+
ipv4_address = ip_allocation.ip
45+
ipv6_address = ip_allocation.ipv6
46+
}
47+
}
48+
}
49+
50+
output "ipv4_addresses" {
51+
description = "A set of IPv4 addresses in your VPC that you want DNS queries to pass through on the way from your network to your VPCs."
52+
value = toset(aws_route53_resolver_endpoint.this.ip_address[*].ip)
53+
}
54+
55+
output "ipv6_addresses" {
56+
description = "A set of IPv6 addresses in your VPC that you want DNS queries to pass through on the way from your network to your VPCs."
57+
value = toset(aws_route53_resolver_endpoint.this.ip_address[*].ipv6)
58+
}
59+
60+
output "default_security_group" {
61+
description = "The default security group ID of the Route53 Resolver Endpoint."
62+
value = one(module.security_group[*].id)
63+
}
64+
65+
output "security_groups" {
66+
description = "A set of security group IDs which is assigned to the Route53 Resolver Endpoint."
2867
value = aws_route53_resolver_endpoint.this.security_group_ids
2968
}
3069

31-
output "subnet_ids" {
32-
description = "A list of the ID of subnets that IP addresses of resolver endpoint are allocated in."
33-
value = distinct(aws_route53_resolver_endpoint.this.ip_address[*].subnet_id)
70+
output "subnets" {
71+
description = "A set of the ID of subnets that IP addresses of resolver endpoint are allocated in."
72+
value = toset(aws_route53_resolver_endpoint.this.ip_address[*].subnet_id)
3473
}
74+
75+
# output "debug" {
76+
# value = {
77+
# for k, v in aws_route53_resolver_endpoint.this :
78+
# k => v
79+
# if !contains(["id", "arn", "direction", "name", "host_vpc_id", "security_group_ids", "protocols", "resolver_endpoint_type", "tags", "tags_all", "ip_address", "timeouts"], k)
80+
# }
81+
# }

0 commit comments

Comments
 (0)