我在Terraform中有一个可用的aws_elastic_beanstalk_environment,我想添加HTTP到HTTPS重定向。
为此,我创建了一个aws_lb_listener
,并希望将load_balancer_arn
设置为指向我的Elastic BeanStalk应用程序。
resource "aws_elastic_beanstalk_environment" "default" {
depends_on = ["aws_route53_record.cert_dns_validate_record"]
name = "${var.app_env_name}"
application = "${var.app_env_name}"
solution_stack_name = "${var.solution_stack_name}"
...
}
resource "aws_lb_listener" "http" {
load_balancer_arn = "${element(aws_elastic_beanstalk_environment.default.load_balancers, 0)}"
port = "80"
protocol = "HTTP"
default_action {
type = "redirect"
redirect {
port = "443"
protocol = "HTTPS"
status_code = "HTTP_301"
}
}
}
当我尝试这样做时,我得到了以下错误,然而:
Error: Error creating LB Listener: ValidationError: 'awseb-e-p-AWSEBLoa-1E9JXK93ULR1I' must be in ARN format
status code: 400, request id: d38933a0-c1e3-43fc-ac22-10659beb86b6
on ../modules/elasticbeanstalk/environment/main.tf line 420, in resource "aws_lb_listener" "http":
420: resource "aws_lb_listener" "http" {
你知道我做错了什么吗?
这是我完整的.tf文件:https://pastebin.com/KhakuvQJ
您不应该像这样操作Elastic Beanstalk环境。这可能会导致问题,您甚至可能有时间解决这些问题。我强烈建议使用第一个elastic_beanstalk_configuration_template
资源来操作您所拥有的默认Elastic Beanstalk配置。然后,您可以将您拥有的模板包含在aws_elastic_beanstalk_environment
中。最后,Elastic Beanstalk只是CloudFormation的一个片段。
请阅读Setting
选项和配置选项列表。