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

Using Terraform Data Template Provider on GCP #3374

Closed
sampcoug opened this issue Apr 3, 2019 · 3 comments
Closed

Using Terraform Data Template Provider on GCP #3374

sampcoug opened this issue Apr 3, 2019 · 3 comments

Comments

@sampcoug
Copy link

sampcoug commented Apr 3, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

I am trying to use Template Provider (https://www.terraform.io/docs/providers/template/index.html) on GCP but getting the error below:

Error: google_compute_instance_template.poc: : invalid or unknown key: user_data

Does Terraform support template_file Data source on Google Cloud Platform?

New or Affected Resource(s)

google_compute_instance_template
  • google_XXXXX

Potential Terraform Configuration

data "google_compute_image" "coreos" {
    family  = "coreos-stable"
    project = "coreos-cloud"
}

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}"
    docker_repo = "${var.xxx}"
    gcp_region = "${var.xxx}"
    etcd_discovery_url = "${file("${var.etcd_discovery_token_file_path}")}",
  }
}

data "ct_config" "service" {
  pretty_print = true
  platform = "gcs"
  content      = "${data.template_file.ct.rendered}"
}

data "template_file" "etcd_discovery_url" {
    template = "${file("/dev/null")}"
}

resource "google_compute_instance_template" "xx" {
  count = "${var.xxx}"
  name           = "${var.xxx}template"
  machine_type   = "${var.xxx}"
  can_ip_forward = false
  **user_data = "${element(data.ct_config.service.*.rendered, count.index)}"**

  tags = ["xx", "xxx"]

  disk {
    source_image = "xxx"
  }

  network_interface {
    #network = "default"
    subnetwork = "xxxx"
    access_config = {
    #The presence of this property assigns a public IP address to each Compute Instance. 
    #We intentionally leave it blank so that external IP is selected automatically.
      nat_ip = ""
    }
  }
}

References

I am getting the error below during the terraform run:

Error: google_compute_instance_template.poc: : invalid or unknown key: user_data
  • #0000
@ghost ghost added the enhancement label Apr 3, 2019
@sampcoug
Copy link
Author

sampcoug commented Apr 3, 2019

I changed user_data with metadata and got past the error for now.

metadata = "${element(data.ct_config.service.*.rendered, count.index)}"

In hashicorp/terraform#20514, that I had opened few weeks ago, following was mentioned:

"The user_data attribute is provider-specific, and not available for google_compute_instance: https://www.terraform.io/docs/providers/google/r/compute_instance.html"

@danawillow
Copy link
Contributor

The last comment reads to me like this has been solved, but feel free to post again if you're still having issues.

@ghost
Copy link

ghost commented Jun 14, 2019

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Jun 14, 2019
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