I have a aws_acm_certificate which I would like to avoid when running my tf locally (because I don't want to acquire a domain name, etc). I also don't want to comment out all the involved code when running locally. Most of my other blocks (such as a provider's assume_role) have been able to be excluded when running locally. How can I do this with a complete resource?
I was expecting to be able to set the count value to a variable in an environment tfvars file:
resource "aws_acm_certificate" "cert" {
count = var.islocal == true ? 0 : 1
domain_name = "www.mysite.com"
validation_method = "DNS"
lifecycle {
create_before_destroy = true
}
}
This leads to other problems, like the need to reference that resource in other place. For example, outputting the result of the resource becomes problematic:
output "acm_cert_domain_validation_options" {
description = "definition of aws certificate requested for cloudfront"
value = aws_acm_certificate.cert[0].domain_validation_options
}
In this case, if the count var is 0 the output will fail on plan and I can't use the same approach there because count is not supported by output.
Other than simply not outputting the value, is there a way to conditional exclude entire blocks safely?