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

Increment template #15476

Closed
SDBrett opened this issue Jul 5, 2017 · 2 comments
Closed

Increment template #15476

SDBrett opened this issue Jul 5, 2017 · 2 comments

Comments

@SDBrett
Copy link

SDBrett commented Jul 5, 2017

I'm using a template to provide initial configuration data for my EC2 instances. Part of that configuration is to set a host name using a defined prefix and the counter as a suffix.

The result is all instances are getting the same name 0, as 0 is the first counter index. I use the same variable to set apply tags to the EC2 instance and node in chef and they increment just fine. The only place it doesn't is with the template.

On face value it appears that the template does not not reevaluate the passed variables after they are first set.

The temple resource is configured as

data "template_file" "file_server" {
  template = "${file("userdata.txt")}"
  vars {
    admin_password="${var.administrator_pw}"
    hostname = "${var.file_server.["hostname_prefix"]}-${count.index}"
  }
}

It is applied against the AWS resource as

[user_data = "${data.template_file.file_server.rendered}"]

In the user data file I am referring to the variable with the following line

Rename-Computer -NewName "${hostname}" -Restart -Confirm:$False

I would expect that my servers are named fs-0, fs-1 ..... but the host name is set as fs-0 for every server.

This is on Terraform 0.9.6

@hashibot
Copy link
Contributor

hashibot commented Jul 5, 2017

This issue has been automatically migrated to hashicorp/terraform-provider-template#12 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to this issue and let us know.

@ghost
Copy link

ghost commented Apr 8, 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 Apr 8, 2020
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

3 participants