I’ve used try() a little bit and I assumed this would work:
output "emr-notebook-cluster-arn" {
value = try(aws_emr_cluster.notebook-cluster.arn, aws_emr_cluster.notebook-cluster[0].arn)
}
However, I get this on plan:
│ Error: Missing resource instance key
│
│ on outputs.tf line 2, in output "emr-notebook-cluster-arn":
│ 2: value = try(aws_emr_cluster.notebook-cluster.arn, aws_emr_cluster.notebook-cluster[0].arn)
│
│ Because aws_emr_cluster.notebook-cluster has "count" set, its attributes
│ must be accessed on specific instances.
│
│ For example, to correlate with indices of a referring resource, use:
│ aws_emr_cluster.notebook-cluster[count.index]
Isn’t try() supposed to suppress that error and move on to the next arg? I’m using terraform 1.1.4