route53.tf 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. resource "aws_route53_resolver_endpoint" "re-dns-in-endpoint" {
  2. name = "re-dns-in-endpoint"
  3. direction = "INBOUND"
  4. security_group_ids = [
  5. module.nodes.re-security-group,
  6. ]
  7. ip_address {
  8. subnet_id = module.vpc.subnets-public[0]
  9. }
  10. ip_address {
  11. subnet_id = module.vpc.subnets-public[1]
  12. }
  13. tags = { Name = "INBOUND-MAGUE-EP" }
  14. }
  15. resource "aws_route53_resolver_endpoint" "re-dns-out-endpoint" {
  16. name = "re-dns-out-endpoint"
  17. direction = "OUTBOUND"
  18. security_group_ids = [
  19. module.nodes.re-security-group,
  20. ]
  21. ip_address {
  22. subnet_id = module.vpc.subnets-public[0]
  23. }
  24. ip_address {
  25. subnet_id = module.vpc.subnets-public[1]
  26. }
  27. tags = { Name = "OUTBOUND-MAGUE-EP" }
  28. }
  29. resource "aws_route53_resolver_rule" "forwarder" {
  30. domain_name = "example.com"
  31. name = "example"
  32. rule_type = "FORWARD"
  33. resolver_endpoint_id = aws_route53_resolver_endpoint.re-dns-out-endpoint.id
  34. target_ip {
  35. ip = module.nodes.node-internal-ips[0]
  36. }
  37. target_ip {
  38. ip = module.nodes.node-internal-ips[1]
  39. }
  40. target_ip {
  41. ip = module.nodes.node-internal-ips[2]
  42. }
  43. }
  44. resource "aws_route53_resolver_rule_association" "myrule" {
  45. resolver_rule_id = aws_route53_resolver_rule.forwarder.id
  46. vpc_id = module.vpc.vpc-id
  47. }