我有一个安全组资源:
resource "aws_security_group" "internal_redis" {
count = "${var.enable_redis ? 1 : 0}"
...
}
和elasticache_cluster
资源:
resource "aws_elasticache_cluster" "redis" {
count = "${var.enable_redis ? 1 : 0}"
...
}
和两个输出资源:
output "security_group_internal_redis_id" {
description = "The ID of the Redis security group"
value = "${aws_security_group.internal_redis.*.id}"
}
output "redis_cluster_address" {
description = "The endpoint to reach Redis"
value = "${aws_elasticache_cluster.redis.cache_nodes.*.address}"
}
当我将enable_redis
设置为false并执行terraform plan
时,出现此错误:
Error: Error running plan: 1 error occurred:
* module.redis.output.redis_cluster_address: Resource 'aws_elasticache_cluster.redis' not found for variable 'aws_elasticache_cluster.redis.cache_nodes.*.address'
一个输出怎么可能没有问题,而错误中仅引用另一个输出?
Terraform v0.11.14
+ provider.archive v1.3.0
+ provider.aws v2.31.0
+ provider.null v2.1.2
+ provider.random v2.2.1
+ provider.template v2.1.2