Skip to content

Commit

Permalink
updating resolver-endpoints and example
Browse files Browse the repository at this point in the history
  • Loading branch information
renebarbosafl committed Aug 27, 2024
1 parent ba1de0a commit a4f5d2f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
12 changes: 4 additions & 8 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,7 @@ module "inbound_resolver_endpoints" {
direction = "INBOUND"
protocols = ["Do53", "DoH"]

ip_address = [
{
subnet_id = module.vpc1.private_subnets[0]
},
{
subnet_id = module.vpc1.private_subnets[1]
}
]
subnet_ids = slice(module.vpc1.private_subnets, 0, 2)

vpc_id = module.vpc1.vpc_id
security_group_name_prefix = "example1-sg-"
Expand All @@ -326,11 +319,14 @@ module "outbound_resolver_endpoints" {
direction = "OUTBOUND"
protocols = ["Do53", "DoH"]

# Using fixed IP addresses
ip_address = [
{
ip = "10.0.0.35"
subnet_id = module.vpc1.private_subnets[0]
},
{
ip = "10.0.1.35"
subnet_id = module.vpc1.private_subnets[1]
}
]
Expand Down
3 changes: 2 additions & 1 deletion modules/resolver-endpoints/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ No modules.
| <a name="input_create"></a> [create](#input\_create) | Whether to create Route53 resolver endpoints | `bool` | `true` | no |
| <a name="input_create_security_group"></a> [create\_security\_group](#input\_create\_security\_group) | Whether to create Security Groups for Route53 Resolver Endpoints | `bool` | `true` | no |
| <a name="input_direction"></a> [direction](#input\_direction) | The resolver endpoint flow direction | `string` | `"INBOUND"` | no |
| <a name="input_ip_address"></a> [ip\_address](#input\_ip\_address) | A list of IP addresses and subnets where Route53 resolver endpoints will be deployed | <pre>list(object({<br> ip = optional(string)<br> subnet_id = string<br> }))</pre> | `[]` | no |
| <a name="input_ip_address"></a> [ip\_address](#input\_ip\_address) | A list of IP addresses and subnets where Route53 resolver endpoints will be deployed | `list(any)` | `[]` | no |
| <a name="input_name"></a> [name](#input\_name) | The resolver endpoint name | `string` | `null` | no |
| <a name="input_protocols"></a> [protocols](#input\_protocols) | The resolver endpoint protocols | `list(string)` | `[]` | no |
| <a name="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description) | The security group description | `string` | `null` | no |
Expand All @@ -44,6 +44,7 @@ No modules.
| <a name="input_security_group_name"></a> [security\_group\_name](#input\_security\_group\_name) | The name of the security group | `string` | `null` | no |
| <a name="input_security_group_name_prefix"></a> [security\_group\_name\_prefix](#input\_security\_group\_name\_prefix) | The prefix of the security group | `string` | `null` | no |
| <a name="input_security_group_tags"></a> [security\_group\_tags](#input\_security\_group\_tags) | A map of tags for the security group | `map(string)` | `{}` | no |
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | A list of subnets where Route53 resolver endpoints will be deployed | `list(any)` | `[]` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags for the Route53 resolver endpoint | `map(string)` | `{}` | no |
| <a name="input_type"></a> [type](#input\_type) | The resolver endpoint IP type | `string` | `"IPV4"` | no |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The VPC ID for all the Route53 Resolver Endpoints | `string` | `""` | no |
Expand Down
5 changes: 3 additions & 2 deletions modules/resolver-endpoints/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
locals {
security_group_ids = var.create && var.create_security_group ? [aws_security_group.this[0].id] : var.security_group_ids
subnet_ids = var.create && length(var.subnet_ids) > 0 ? [for subnet in var.subnet_ids : { subnet_id = subnet }] : var.subnet_ids
}

resource "aws_route53_resolver_endpoint" "this" {
Expand All @@ -12,11 +13,11 @@ resource "aws_route53_resolver_endpoint" "this" {
security_group_ids = local.security_group_ids

dynamic "ip_address" {
for_each = var.ip_address
for_each = length(var.ip_address) == 0 ? local.subnet_ids : var.ip_address

content {
ip = lookup(ip_address.value, "ip", null)
subnet_id = ip_address.value.subnet_id
subnet_id = each.value.subnet_id
}
}

Expand Down
13 changes: 8 additions & 5 deletions modules/resolver-endpoints/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ variable "type" {
default = "IPV4"
}

variable "subnet_ids" {
description = "A list of subnets where Route53 resolver endpoints will be deployed"
type = list(any)
default = []
}

variable "ip_address" {
description = "A list of IP addresses and subnets where Route53 resolver endpoints will be deployed"
type = list(object({
ip = optional(string)
subnet_id = string
}))
default = []
type = list(any)
default = []
}

variable "security_group_ids" {
Expand Down

0 comments on commit a4f5d2f

Please sign in to comment.