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

Reference template_file rendering in count #6111

Closed
ghost opened this issue Apr 10, 2016 · 2 comments
Closed

Reference template_file rendering in count #6111

ghost opened this issue Apr 10, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 10, 2016

I am using a template resource to construct a complex list of cidr ranges and want to use it to create the count parameter as shown below.

count = "${length(split(",", template_file.test.rendered))}"

This returns the following error:
resource count can't reference resource variable: template_file.test.rendered

Is this by design that you can't reference a template_file rendering in the count parameter?

Thanks!

@apparentlymart
Copy link
Contributor

Hi @jmfuchs!

Unfortunately yes it is intentional -- though annoying, I agree -- that you can't reference resource attributes in count. The reason for this is that count needs to be handed during planning, which means that some resources may not have been created yet.

We're working on a new concept called "data sources" over in #4169 which represents the kind of thing template_file is: loading or computing some data to use elsewhere in the configuration, rather than creating and managing a resource. The intent is that template_file would become a data source in future, and would then be permitted to be used in count since its result would be known during planning.

#4961 is where the work for this feature is currently being done, with the intent that it be included in the 0.7 release of Terraform.

For now I'm going to close this issue since I think it's covered by these other tickets. Thanks for the ticket and I'm sorry I don't have a good workaround for you right now.

@github-actions
Copy link

github-actions bot commented Jun 3, 2021

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 Jun 3, 2021
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