-
Notifications
You must be signed in to change notification settings - Fork 90
Increment template #12
Comments
I ran into the same trouble you did with the template not rendering as expected. I needed to get the I found hashicorp/terraform#2167 which mentioned a solution that didn't work for me either. What solved it was adding a 'count' to the template and referencing it in the
Here's how I'm calling it from my
this is on Terraform v0.9.11 |
I've updated my code to reflect what you posted. Though I get an error in the data resource if I do so.
data "template_file" "file_server" { vars { In the file for the EC2 instance I'm using resource "aws_instance" "file_server" {
|
I have changed the way that I am incrementing the hostname when calling the template. The template now looks like `data "template_file" "file_server" { vars { "${var.file_server["number"]}" is the variable used to specify the number of AWS instances to create. |
This issue was originally opened by @SDBrett as hashicorp/terraform#15476. It was migrated here as a result of the provider split. The original body of the issue is below.
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
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
The text was updated successfully, but these errors were encountered: