运行“地形计划”时输出值错误

时间:2019-11-29 15:30:26

标签: terraform

我有一个安全组资源:

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

0 个答案:

没有答案