Terraform : module output

Well nothing complex, it’s just that output is looking for the resource which is not created, as terraform is still referring to that resource due to which it is throwing an error.

While there are several ways to tackle this issue, one of them is to concatenate all the resources as list in one step, and retrieve a single element using terraform in-built functions.

Your output should be something like this when you are using count as a condition to create resources. If the resource is created the output will be the id of the resource. When the count is zero, output will be empty without any errors.

output id {
  description = "The ID of the directory"
  value       = element(concat(aws_directory_service_directory.ds.*.id, list("")), 0)
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top