From 0097eade4ec44ee8181a3acab4e76dc257add001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=AA=20Barbosa?= Date: Fri, 14 Jun 2024 10:07:00 -0300 Subject: [PATCH] add: support for static ip address --- examples/complete/main.tf | 32 ++++++++++++++++++------- modules/resolver-endpoints/README.md | 2 +- modules/resolver-endpoints/main.tf | 5 ++-- modules/resolver-endpoints/variables.tf | 11 +++++---- 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/examples/complete/main.tf b/examples/complete/main.tf index c5642cb..afcd83b 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -288,10 +288,18 @@ module "resolver_rule_associations" { module "inbound_resolver_endpoints" { source = "../../modules/resolver-endpoints" - name = "example1" - direction = "INBOUND" - protocols = ["Do53", "DoH"] - subnet_ids = module.vpc1.private_subnets + name = "example1" + direction = "INBOUND" + protocols = ["Do53", "DoH"] + + ip_address = [ + { + subnet_id = module.vpc1.private_subnets[0] + }, + { + subnet_id = module.vpc1.private_subnets[1] + } + ] vpc_id = module.vpc1.vpc_id security_group_name_prefix = "example1-sg-" @@ -306,10 +314,18 @@ module "inbound_resolver_endpoints" { module "outbound_resolver_endpoints" { source = "../../modules/resolver-endpoints" - name = "example2" - direction = "OUTBOUND" - protocols = ["Do53", "DoH"] - subnet_ids = module.vpc1.private_subnets + name = "example2" + direction = "OUTBOUND" + protocols = ["Do53", "DoH"] + + ip_address = [ + { + subnet_id = module.vpc1.private_subnets[0] + }, + { + subnet_id = module.vpc1.private_subnets[1] + } + ] vpc_id = module.vpc1.vpc_id security_group_name_prefix = "example2-sg-" diff --git a/modules/resolver-endpoints/README.md b/modules/resolver-endpoints/README.md index e110b5c..ee5a46a 100644 --- a/modules/resolver-endpoints/README.md +++ b/modules/resolver-endpoints/README.md @@ -34,6 +34,7 @@ No modules. | [create](#input\_create) | Whether to create Route53 resolver endpoints | `bool` | `true` | no | | [create\_security\_group](#input\_create\_security\_group) | Whether to create Security Groups for Route53 Resolver Endpoints | `bool` | `true` | no | | [direction](#input\_direction) | The resolver endpoint flow direction | `string` | `"INBOUND"` | no | +| [ip\_address](#input\_ip\_address) | A list of IP addresses and subnets where Route53 resolver endpoints will be deployed |
list(object({
ip = optional(string)
subnet_id = string
}))
| `[]` | no | | [name](#input\_name) | The resolver endpoint name | `string` | `null` | no | | [protocols](#input\_protocols) | The resolver endpoint protocols | `list(string)` | `[]` | no | | [security\_group\_description](#input\_security\_group\_description) | The security group description | `string` | `null` | no | @@ -43,7 +44,6 @@ No modules. | [security\_group\_name](#input\_security\_group\_name) | The name of the security group | `string` | `null` | no | | [security\_group\_name\_prefix](#input\_security\_group\_name\_prefix) | The prefix of the security group | `string` | `null` | no | | [security\_group\_tags](#input\_security\_group\_tags) | A map of tags for the security group | `map(string)` | `{}` | no | -| [subnet\_ids](#input\_subnet\_ids) | A list of subnets where Route53 resolver endpoints will be deployed | `list(string)` | `[]` | no | | [tags](#input\_tags) | A map of tags for the Route53 resolver endpoint | `map(string)` | `{}` | no | | [type](#input\_type) | The resolver endpoint IP type | `string` | `"IPV4"` | no | | [vpc\_id](#input\_vpc\_id) | The VPC ID for all the Route53 Resolver Endpoints | `string` | `""` | no | diff --git a/modules/resolver-endpoints/main.tf b/modules/resolver-endpoints/main.tf index 4440044..0664c50 100644 --- a/modules/resolver-endpoints/main.tf +++ b/modules/resolver-endpoints/main.tf @@ -12,10 +12,11 @@ resource "aws_route53_resolver_endpoint" "this" { security_group_ids = local.security_group_ids dynamic "ip_address" { - for_each = var.subnet_ids + for_each = var.ip_address content { - subnet_id = ip_address.value + ip = ip_address.value.ip + subnet_id = ip_address.value.subnet_id } } diff --git a/modules/resolver-endpoints/variables.tf b/modules/resolver-endpoints/variables.tf index fcdb5b0..808473f 100644 --- a/modules/resolver-endpoints/variables.tf +++ b/modules/resolver-endpoints/variables.tf @@ -28,10 +28,13 @@ variable "type" { default = "IPV4" } -variable "subnet_ids" { - description = "A list of subnets where Route53 resolver endpoints will be deployed" - type = list(string) - 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 = [] } variable "security_group_ids" {