Skip to content
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

Terraform: data.template_file does not seem to run. #20560

Closed
sampcoug opened this issue Mar 5, 2019 · 2 comments
Closed

Terraform: data.template_file does not seem to run. #20560

sampcoug opened this issue Mar 5, 2019 · 2 comments

Comments

@sampcoug
Copy link

sampcoug commented Mar 5, 2019

Terraform Version

Terraform v0.11.11
+ provider.google v2.1.0
+ provider.null v2.1.0
+ provider.template v2.1.0

Terraform Configuration Files

**main.tf**

data "template_file" "ct" {
  count = "${var.count}"
  depends_on  = ["data.template_file.etcd_discovery_url"]
  template = "${file("config.tpl")}"
  vars { 
...
    etcd_discovery_url = "${file("${var.etcd_discovery_token_file_path}")}",
  }
}

#Create a new instance
resource "google_compute_instance" "vm_instance1" {
  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 {
    subnetwork = "xxx-us-west1-public-net"
    access_config = {
      // Ephemeral IP
    }
  }
  metadata_startup_script = "${element(data.template_file.ct.*.rendered, count.index)}"


**config.tpl**

#!/bin/bash
echo hellogoogle > /tmp/hello.txt

Debug Output

2019-03-04T15:09:26.923-0800 [DEBUG] plugin.terraform-provider-google_v2.1.0_x4: "value": "#etcd:\n # generate a new token for each unique cluster from https://discovery.etcd.io/new?size=3\n # specify the initial size of your cluster with ?size=X\n discovery: https://discovery.etcd.io/54d81aa7db300da1a2f5aa520a533ca0\n # multi-region and multi-cloud deployments need to use $public_ipv4\n advertise_client_urls: http://{PRIVATE_IPV4}:2379,http://{PRIVATE_IPV4}:4001\n initial_advertise_peer_urls: http://{PRIVATE_IPV4}:2380\n # listen on both the official ports and the legacy ports\n # legacy ports can be omitted if your application doesn't depend on them\n listen_client_urls: http://0.0.0.0:2379,http://0.0.0.0:4001\n listen_peer_urls: http://{PRIVATE_IPV4}:2380,http://{PRIVATE_IPV4}:7001\n\n#!/bin/bash\necho hellogoogle \u003e /tmp/hello.txt\n \n \n\n\n\n\n\n\n\n"

Crash Output

Expected Behavior

Terraform should have run and made the changes as per the - config.tpl file.

Actual Behavior

Looking at the terraform log, the content of the config file seems to load but it does not run.

Steps to Reproduce

Create main.tf and config.tpl files from the contents and try running the terraform.

-->

@ghost
Copy link

ghost commented Mar 5, 2019

This issue has been automatically migrated to hashicorp/terraform-provider-google#3194 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to hashicorp/terraform-provider-google#3194.

@ghost
Copy link

ghost commented Mar 29, 2020

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.

@ghost ghost locked and limited conversation to collaborators Mar 29, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants