地形aws_elastic_beanstalk_environment将HTTP流量重定向到HTTPS

时间:2019-09-15 11:33:44

标签: amazon-web-services terraform

我正在使用Terraform来提供Elasticbeanstalk环境。我想将所有HTTP通信重定向到HTTPS。这是我当前的配置:

resource "aws_elastic_beanstalk_environment" "env" {
  ...

  # Configure the default listener (port 80) on a classic load balancer.
  setting {
    namespace = "aws:elb:listener:80"
    name      = "InstancePort"
    value     = "80"
  }
  setting {
    namespace = "aws:elb:listener:80"
    name      = "ListenerEnabled"
    value     = "true"
  }

  # Configure additional listeners on a classic load balancer.
  setting {
    namespace = "aws:elb:listener:443"
    name      = "ListenerProtocol"
    value     = "HTTPS"
  }
  setting {
    namespace = "aws:elb:listener:443"
    name      = "InstancePort"
    value     = "80"
  }
  setting {
    namespace = "aws:elb:listener:443"
    name      = "ListenerEnabled"
    value     = "true"
  }

  # Modify the default stickiness and global load balancer policies for a classic load balancer.
  setting {
    namespace = "aws:elb:policies"
    name      = "ConnectionSettingIdleTimeout"
    value     = "60"
  }

  setting {
    namespace = "aws:elbv2:listener:443"
    name      = "SSLCertificateArns"
    value     = "${aws_acm_certificate.cert.arn}"
  }

  setting {
    namespace = "aws:elb:listener:443"
    name      = "SSLCertificateId"
    value     = "${aws_acm_certificate.cert.arn}"
  }

我已经尝试过各种在线发布的解决方案,但是实际上都无法使用。知道我当前的配置有什么问题吗?预先感谢。

编辑:整个配置(出于某种原因,stackoverflow不允许发布所有内容)https://pastebin.com/aMHgSiXr

0 个答案:

没有答案