elbclassic.tf.skipped 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. module "public_dns_record" {
  2. source = "../../submodules/dns/public_ALIAS_record"
  3. name = "keycloak.${var.dns_info["public"]["zone"]}"
  4. target_dns_name = aws_elb.external.dns_name
  5. target_zone_id = aws_elb.external.zone_id
  6. dns_info = var.dns_info
  7. providers = {
  8. aws.mdr-common-services-commercial = aws.mdr-common-services-commercial
  9. }
  10. }
  11. resource "aws_elb" "external" {
  12. name = "keycloak-external-elb"
  13. subnets = var.public_subnets
  14. security_groups = [ aws_security_group.elb_external.id ]
  15. access_logs {
  16. bucket = "xdr-elb-${ var.environment }"
  17. enabled = true
  18. }
  19. # We want client certs, so SSL must be terminated on the instance
  20. listener {
  21. instance_port = 8443
  22. instance_protocol = "TCP"
  23. lb_port = 443
  24. lb_protocol = "TCP"
  25. #ssl_certificate_id = aws_acm_certificate.cert.arn
  26. }
  27. listener {
  28. instance_port = 80
  29. instance_protocol = "HTTP"
  30. lb_port = 8080
  31. lb_protocol = "HTTP"
  32. }
  33. health_check {
  34. healthy_threshold = 2
  35. unhealthy_threshold = 2
  36. timeout = 3
  37. target = "HTTPS:8443/"
  38. interval = 10
  39. }
  40. cross_zone_load_balancing = true
  41. idle_timeout = 300
  42. connection_draining = true
  43. connection_draining_timeout = 300
  44. tags = merge(var.standard_tags, var.tags)
  45. }
  46. # Create a new load balancer attachment
  47. resource "aws_elb_attachment" "external_attachment" {
  48. count = var.keycloak_instance_count
  49. elb = aws_elb.external.id
  50. instance = aws_instance.instance[count.index].id
  51. }
  52. # No stickiness on TCP
  53. #resource "aws_lb_cookie_stickiness_policy" "external" {
  54. # name = "Stickiness"
  55. # load_balancer = aws_elb.external.name
  56. # lb_port = 443
  57. # cookie_expiration_period = 600
  58. #}
  59. # No policy on TCP
  60. ## Seems like there should be an easier way for terraform to assign the default policy, but
  61. ## this is how it's done according to https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/load_balancer_listener_policy
  62. #resource "aws_load_balancer_policy" "elb_external_ssl_policy" {
  63. # load_balancer_name = aws_elb.external.name
  64. # policy_name = "CopyOfELBSecurityPolicy-TLS-1-1-2017-01"
  65. # policy_type_name = "SSLNegotiationPolicyType"
  66. #
  67. # policy_attribute {
  68. # name = "Reference-Security-Policy"
  69. # value = "ELBSecurityPolicy-TLS-1-1-2017-01" # ALBs have a (superior?) "ELBSecurityPolicy-FS-1-2-Res-2019-08", but this will have to do for ELB
  70. # }
  71. #}
  72. #
  73. #resource "aws_load_balancer_listener_policy" "elb-external-listener-policies-443" {
  74. # load_balancer_name = aws_elb.external.name
  75. # load_balancer_port = 443
  76. #
  77. # policy_names = [
  78. # aws_load_balancer_policy.elb_external_ssl_policy.policy_name
  79. # ]
  80. #}
  81. ### Client Certificate Configuration
  82. #
  83. # No AWS LBs support client certificates, unfortunately.