【发布时间】:2019-02-01 14:54:47
【问题描述】:
我正在尝试为 if-else 条件创建资源 aws_lb_listener 并使用 terraform 插值。但它告诉我基础设施没有变化。但是,它尚未在基础架构上创建 https 侦听器。下面的代码有什么遗漏吗?
alb.tf
resource "aws_lb_listener" "https" {
count = "${var.https_listener_enable == true ? 1 : 0}"
load_balancer_arn = "${aws_lb.main.arn}"
port = "443"
protocol = "HTTPS"
ssl_policy = "ELBSecurityPolicy-2016-08"
certificate_arn = "arn:aws:iam::187416307283:server-certificate/test_cert_rab3wuqwgja25ct3n4jdj2tzu4"
default_action {
type = "fixed-response"
fixed_response {
content_type = "text/plain"
message_body = "Nothing is here. Go Away."
status_code = "200"
}
}
}
变量.tf
variable "https_listener_enable" {}
main.tf
module "public_alb" {
source = "../modules/alb"
load_balancer_name = "example-production"
https_listener_enable = true
security_groups = ["${module.security_group.sg_http}"]
load_balancer_is_internal = false
idle_timeout = 60
enable_deletion_protection = false
enable_http2 = true
tags = "${map("Environment", "production",
"Name", "example-production",)}"
subnets = "${module.vpc.public_subnets}"
vpc_id = "${module.vpc.vpc_id}"
}
【问题讨论】:
-
您的三元组要求将
https_listener_enable设置为true,因此您可能不会在任何地方这样做。至少您没有在任何显示的代码中执行此操作。 -
在 main.tf 中,我将该变量作为 true 传递。
标签: terraform