-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
template_file data source doesn't allow count meta-parameter #7919
Comments
Hi @laggyluke - we're aware of the limitation of not being able to use |
Yes, I'm facing the same issue while trying to convert this to data sources usage after 0.7.0 release and drop the deprecation warning:
|
@jen20 It would be useful to update the Migrating to Data Sources section of the upgrade docs (https://www.terraform.io/upgrade-guides/0-7.html) with a note about this, so that folks don't upgrade all their files before realizing that they simply need to revert it, since this important functionality is missing. |
Any clever workarounds? :) |
I'm using the data e.g.
|
There is no workaround for this in case you are doing something more than just identical template where you can just replace {count}. For example, generating self signed certificates for multiple nodes of a cluster with For, now I will keep using the deprecated resources until it's fixed. |
@RichardKnop Specially with tls_cert_request, when you start using deprecated resource type for count usage. Discussed here: #7821
|
Also, FYI but the docs definitely have examples where data.template_file use the count meta parameter. For example: https://www.terraform.io/docs/configuration/interpolation.html |
Hi all! This was actually fixed in #8635, which was included in the Terraform 0.7.3 release. Sorry that this ticket ended up getting missed when posting updates! |
@apparentlymart I'm using the latest Terraform (0.10.0), and I still can't reference rendered data by
With: variable "environments" {
default = ["dev", "prod"]
description = "Environment to create resources in."
}
data "template_file" "policy" {
count = "${length(var.environments)}"
template = ""
}
resource "aws_s3_bucket" "conf" {
count = "${length(var.environments)}"
bucket = "conf-${var.environments[count.index]}"
policy = "${data.template_file.policy[count.index].rendered}"
} If I use |
Hi @shatil, At this time it doesn't work to use the policy = "${data.template_file.policy.*.rendered[count.index]}" Writing it this way allows Terraform to understand that only this specific index is needed, preventing overly-conservative behavior when the count is increased. Supporting the more intuitive syntax you tried here is one of the things on our early list of configuration language improvements we plan to make in a future version. We'll have more to share about that soon. (If you have any follow-up questions/feedback here, let's take it to a fresh issue, since this is not directly related to this original issue as filed and continuing the conversation here will create notification noise for the several people watching this one.) |
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. |
Terraform Version
Terraform v0.7.0
Affected Resource(s)
Terraform Configuration Files
The new data source fails:
While the legacy resource works fine (although with a deprecation warning):
Expected Behavior
Something similar to what legacy resource gives:
Actual Behavior
Steps to Reproduce
Simply run
terraform plan
with the above configuration file.The text was updated successfully, but these errors were encountered: