-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to find status/error log on the data template_file. #20514
Comments
Found a way to enable verbose logging but still not understanding why the template_file failed to run. |
Hi @sampcoug, I formatted your comment so it's a bit easier to read, but did not change any of the content. It would help if you could update this with the rest of your terraform configuration files so we can see how you are using the rendered template. The output from terraform plan/apply would be helpful, too. |
Hi @mildwonkey , thank you so much for your response. Below is my terraform configuration file(main.tf). #Specify the provider
provider "google" {
project = "xxx"
#region = "xxx"
#zone = "xxx"
}
terraform {
backend "gcs" {
bucket = "xxx"
prefix = "xxx"
credentials = "xxx"
}
}
data "template_file" "ct" {
count = "${var.count}"
depends_on = ["data.template_file.etcd_discovery_url"]
template = "${file("xxx.tpl")}"
vars {
hostname = "${var.xxx}"
shortname = "${var.xxx}"
shortnamexxx = "${var.xxx}"
shortnametxxxe = "${var.xxx}"
docker_repo = "${var.xxx}"
gcp_region = "${var.xxx}"
message = "${var.xxx}"
etcd_discovery_url = "${file("${var.xxx}")}",
}
}
data "ct_config" "service" {
pretty_print = true
platform = "gce"
content = "${data.template_file.ct.rendered}"
}
data "template_file" "etcd_discovery_url" {
template = "${file("/dev/null")}"
}
resource "null_resource" "etcd" {
provisioner "local-exec" {
command = "curl https://discovery.etcd.io/new?size=${var.count} > ${var.etcd_discovery_token_file_path}"
}
}
#Create a new instance
resource "google_compute_instance" "vm_instance1" {
name = "${var.xxx}"
machine_type = "${var.machine_type}"
zone = "xxx"
boot_disk {
initialize_params {
image = "coreos-cloud/coreos-stable-1911-4-0-v20181127"
}
}
network_interface {
#network = "xxx"
subnetwork = "xxx"
access_config = {
// Ephemeral IP
}
}
}
#Create a new instance
resource "google_compute_instance" "vm_instance2" {
name = "${var.env_prefix}"
machine_type = "${var.machine_type}"
zone = "xxx"
boot_disk {
initialize_params {
image = "coreos-cloud/coreos-stable-1911-4-0-v20181127"
}
}
network_interface {
#network = "xxx"
subnetwork = "xxx"
access_config = {
// Ephemeral IP
}
}
} |
Tip: you can use triple backticks before and after your text to format it as code blocks :) |
Ah.. I was wondering how you were formatting. I will remember for next time. Tx! |
Thank you for the additional information! Based on the configuration you shared, I am not certain what you expect to happen with the template_files. You have three data sources, but none of them are referenced in your resources. Is there something missing from the configuration you've shared? If not, here is an example of how to use the ct_config data source from the
|
Thanks! Eyeballing at my configs again, I noticed that I am missing the following user_data reference on my "google_compute_instance" resource.
Something like this may be? I will try and see hows it works.
|
I am getting the following error when I run
Similar setup has worked for me for AWS. |
The user_data attribute is provider-specific, and not available for I'm going to close this issue, since we answered your specific question about rendering templates. If you need further help with your configuration, you can open a new issue, but it's generally better to use one of the community forums where there are far more people ready to help. Cheers! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Terraform Version
Terraform Configuration Files
Debug Output
Crash Output
Terraform runs successfully
Expected Behavior
The template file should get loaded during the Terraform run and complete the configuration desired.
Actual Behavior
Terraform run completed but template_file failed to run and there are no errors to see what went wrong.
Steps to Reproduce
Please list the full steps required to reproduce the issue, for example:
terraform init
terraform plan
terraform apply
Additional Context
The text was updated successfully, but these errors were encountered: