generated from appvia/terraform-aws-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresolvers.tf
39 lines (32 loc) · 1.16 KB
/
resolvers.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
## Provision the security group for the dns resolvers
# tfsec:ignore:aws-ec2-no-public-egress-sgr
module "dns_security_group" {
count = local.enable_dns_security_group ? 1 : 0
source = "terraform-aws-modules/security-group/aws"
version = "5.3.0"
name = "dns-resolvers-${var.name}"
description = "Allow DNS traffic to the route53 resolvers"
ingress_cidr_blocks = ["10.0.0.0/8"]
ingress_rules = ["dns-tcp", "dns-udp"]
egress_rules = ["dns-tcp", "dns-udp"]
tags = merge(var.tags, { "Name" : "dns-resolvers-${var.name}" })
vpc_id = local.vpc_id
}
## Provision an outbound resolver if required
resource "aws_route53_resolver_endpoint" "outbound" {
count = local.enable_outbound_resolver ? 1 : 0
name = "outbound-${var.name}"
direction = "OUTBOUND"
protocols = var.resolvers.outbound.protocols
security_group_ids = [module.dns_security_group[0].security_group_id]
tags = var.tags
dynamic "ip_address" {
for_each = local.private_subnet_ids
content {
subnet_id = ip_address.value
}
}
depends_on = [
module.vpc,
]
}