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

Need way to interpolate count index as other than zero-based (for host names) #686

Closed
ecweaver opened this issue Dec 16, 2014 · 7 comments · Fixed by #1068
Closed

Need way to interpolate count index as other than zero-based (for host names) #686

ecweaver opened this issue Dec 16, 2014 · 7 comments · Fixed by #1068

Comments

@ecweaver
Copy link

Around our shop, server names with numbers are done one-based.
Since the only way, in a counted resource, to interpolate a ${count.index} is zero-based, this causes annoying zero-based server names.

IWBNI there were either another "part" for count, say index1, or a way to specify an offset such as indexplus 1 or a way to nest those references and an "add" interpolation. Something, anything, please.

@mitchellh
Copy link
Contributor

Hm, I think we probably need to introduce basic math into our interpolation language or something...

@tkak
Copy link
Contributor

tkak commented Jan 16, 2015

It would be very helpful if terraform supported basic math feature or index1 feature.

@mitchellh
Copy link
Contributor

@tkak It is coming )

@mitchellh
Copy link
Contributor

Done. We added math support in for int types so you can do things like ${count.index+1} now.

@jimmycuadra
Copy link
Contributor

I think there might be a related issue for this, but what about left padding a number to a certain number of digits so you can use the count to create server names like server-01, server-02, etc.?

@mitchellh
Copy link
Contributor

@jimmycuadra There is a sprintf-style issue on page 1 somewhere. :)

@ghost
Copy link

ghost commented May 4, 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 May 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants