I'm getting the following error during my terraform apply (but it doesn't show up during terraform plan):
Error applying plan:
2016/11/14 14:10:49 [DEBUG] plugin: waiting for all plugin processes to complete...
1 error(s) occurred:
* data.template_file.chef-environment: failed to render : 2:15: unknown variable accessed: name
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
Pertinent debug output here:
https://gist.github.com/jcderose/ded36006a6368346b32ad9ea77926b74
The "app1_db_host" variable declaration (below) is the only line I changed in data.template_file.chef-environment. (That variable used to receive the value of a local variable instead, and worked that way.)
data "template_file" "chef-environment" {
template = "path/to/template"
vars {
...
app1_db_host = "${coalesce(module.app1.db_fqdn, module.app0.db_fqdn)}"
}
}
We have some new use cases where app1 does not have its own standalone DB host, so the output of "module.app1.db_fqdn" is nonexistent. (In those cases, the variable app1_db_host should be module.app0.db_fqdn, which is always created/declared.)
(1) Am I correct that the error message above could stem from an issue like this?
(2) What can I do to resolve this issue? I already looked into setting a default blank string for the output variable (module.app1.db_fqdn) or setting the output variable module.app1.db_fqdn equal to "${element(aws_route53_record.db_master.*.fqdn, 0)}". Neither of those worked.