# r53-resolver

Creates Route 53 Resolver endpoints and rules for hybrid DNS resolution between a VPC and external DNS servers.

Provisions inbound and outbound resolver endpoints from a single module, along with forwarding rules and their VPC associations. Inbound endpoints let external resolvers query into the VPC. Outbound endpoints let the VPC forward specific domain queries to on-premises or other external DNS servers. Rules define which domains get forwarded and where, and can be associated with one or more VPCs.

## Usage

```hcl
module "r53_resolver" {
  source  = "hcassc.jfrog.io/iac-tf-modules-virtual__networking/r53-resolver/aws"
  version = "0.2.0"

  name_prefix = "acme-prod-internal"

  endpoints = {
    outbound = {
      direction             = "OUTBOUND"
      endpoint_name_suffix  = "dc-outbound"
      endpoint_type         = "IPV4"
      security_group_ids    = [module.security_group.id]
      interfaces = [
        { subnet_id = module.vpc.private_subnet_ids["a"] },
        { subnet_id = module.vpc.private_subnet_ids["b"] },
      ]
    }

    inbound = {
      direction             = "INBOUND"
      endpoint_name_suffix  = "dc-inbound"
      endpoint_type         = "IPV4"
      security_group_ids    = [module.security_group.id]
      interfaces = [
        { subnet_id = module.vpc.private_subnet_ids["a"] },
        { subnet_id = module.vpc.private_subnet_ids["b"] },
      ]
    }
  }

  rules = {
    to_onprem = {
      domain_name       = "corp.internal"
      endpoint_key      = "outbound"
      rule_name_suffix  = "to-onprem"
      target_ips = [
        { ip = "10.50.0.10" },
        { ip = "10.50.0.11" },
      ]
      vpc_ids = [module.vpc.id]
    }
  }
}
```

<!-- BEGIN_TF_DOCS — DO NOT EDIT BELOW THIS LINE -->

## Requirements

| Name                                                                     | Version            |
| ------------------------------------------------------------------------ | ------------------ |
| <a name="requirement_terraform"></a> [terraform](#requirement_terraform) | >= 1.15.0, < 2.0.0 |
| <a name="requirement_aws"></a> [aws](#requirement_aws)                   | >= 6.0, < 7.0      |

## Providers

| Name                                             | Version       |
| ------------------------------------------------ | ------------- |
| <a name="provider_aws"></a> [aws](#provider_aws) | >= 6.0, < 7.0 |

## Resources

| Name                                                                                                                                                        | Type     |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| [aws_route53_resolver_endpoint.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_endpoint)                 | resource |
| [aws_route53_resolver_rule.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_rule)                         | resource |
| [aws_route53_resolver_rule_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_rule_association) | resource |

## Inputs

| Name                                                               | Description                                                                                                            | Type                                                                                                                                                                                                                                                                                                                           | Default | Required |
| ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- | :------: |
| <a name="input_name_prefix"></a> [name_prefix](#input_name_prefix) | Prefix prepended to resource names created by this module                                                              | `string`                                                                                                                                                                                                                                                                                                                       | n/a     |   yes    |
| <a name="input_endpoints"></a> [endpoints](#input_endpoints)       | Map of resolver endpoint logical key to configuration                                                                  | <pre>map(object({<br/> direction = string<br/> endpoint_name_suffix = string<br/> endpoint_type = optional(string, "IPV4")<br/> security_group_ids = list(string)<br/> interfaces = list(object({<br/> subnet_id = string<br/> ip = optional(string)<br/> }))<br/> tags = optional(map(string), {})<br/> }))</pre>             | `{}`    |    no    |
| <a name="input_rules"></a> [rules](#input_rules)                   | Map of resolver rule logical key to configuration.<br/>endpoint_key must reference an OUTBOUND entry in var.endpoints. | <pre>map(object({<br/> domain_name = string<br/> rule_type = optional(string, "FORWARD")<br/> endpoint_key = string<br/> rule_name_suffix = string<br/> target_ips = list(object({<br/> ip = string<br/> port = optional(number, 53)<br/> }))<br/> vpc_ids = list(string)<br/> tags = optional(map(string), {})<br/> }))</pre> | `{}`    |    no    |
| <a name="input_tags"></a> [tags](#input_tags)                      | Resource tags to apply to all resources                                                                                | `map(string)`                                                                                                                                                                                                                                                                                                                  | `{}`    |    no    |

## Outputs

| Name                                                                                               | Description                                                               |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
| <a name="output_endpoint_arns"></a> [endpoint_arns](#output_endpoint_arns)                         | Map of resolver endpoint logical key to endpoint ARN                      |
| <a name="output_endpoint_ids"></a> [endpoint_ids](#output_endpoint_ids)                            | Map of resolver endpoint logical key to endpoint ID                       |
| <a name="output_endpoint_ip_addresses"></a> [endpoint_ip_addresses](#output_endpoint_ip_addresses) | Map of resolver endpoint logical key to its list of assigned IP addresses |
| <a name="output_rule_arns"></a> [rule_arns](#output_rule_arns)                                     | Map of resolver rule logical key to rule ARN                              |
| <a name="output_rule_ids"></a> [rule_ids](#output_rule_ids)                                        | Map of resolver rule logical key to rule ID                               |

<!-- END_TF_DOCS — DO NOT EDIT ABOVE THIS LINE -->
