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. #3194

Closed
ghost opened this issue Mar 5, 2019 · 6 comments
Closed

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

ghost opened this issue Mar 5, 2019 · 6 comments
Labels

Comments

@ghost
Copy link

ghost commented Mar 5, 2019

This issue was originally opened by @sampcoug as hashicorp/terraform#20560. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

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

Affected Resource(s)

  • template_file

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.

-->

@rileykarson
Copy link
Collaborator

@paddycarver: Should this have landed in the Google provider? It looks like an issue with the template_file to me.

@sampcoug
Copy link

sampcoug commented Mar 6, 2019

@rileykarson, I apologize but I am not sure whether it's a problem with the ct provider or the template_file. I have created several variations of the file but none of them seem to run and I can't find the errors either.

@sampcoug
Copy link

sampcoug commented Mar 7, 2019

Hello All, I will raise the issue with https://github.com/coreos/terraform-provider-ct/issues team. Hopefully, the provider maintainer team can help.

@paddycarver
Copy link
Contributor

Hey @sampcoug, I'm not sure I'm following what the question is here. Are you still having this issue?

modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Mar 2, 2020
Signed-off-by: Modular Magician <magic-modules@google.com>
modular-magician added a commit that referenced this issue Mar 2, 2020
Signed-off-by: Modular Magician <magic-modules@google.com>
@paddycarver paddycarver removed their assignment Mar 9, 2020
@melinath
Copy link
Collaborator

melinath commented Feb 6, 2023

Sounds like this was not an issue with google_compute_instance.

@github-actions
Copy link

github-actions bot commented Mar 9, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants