-
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
helper/resource: Use base 36 to generate incremental ids #16997
Conversation
+1 |
I got here from one of the many references. I have a couple of questions:
Finally @apparentlymart what's the appetite/timeline to get this type of change into Core? I have hit this issue with ALB and it's quite annoying. cc/ @weavenet |
|
|
I could get behind that. Say we go with date kept in 6 characters, that covers timestamps (in seconds) until Heck make it 7 characters for the timestamp and we are covered until 04/05/4453 and have a nice round 10 characters generated for the suffix (starting with 0 for the next 20 years). |
Even with random suffixes, the number of resources this would need to handle is pretty low, so it seems like collisions can be minimized even with a fairly small number of bits. 1,000 ALBs with the same prefix seems like a fairly high number, but (if I did the math right) with just 16 hex digits (64 bits) the chance of a single collision is on the order of 10^-12%. Does Terraform already check for collisions internally within the resource names in a given configuration? For example, if it's assigning 1,000 ALB names with a given prefix, it could generate them randomly, and detect and regenerate any duplicates before assigning the names to the resources. It doesn't take many bits to minimize the collisions and reduce how long it would take to assign them. Is the implementation also able to check if a resource name is already taken on AWS before assigning it? |
any updates here? |
Hello, and sorry for the long silence! |
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. |
After reading discussions (1, 2, 3, 4, 5, 6) about the managing of the "prefixed names", here's a suggestion to improve the automatic generation of suffixes in terraform.
What changes
[a-z0-9]
) this gives a wider range of characters to express the number making the suffix even more compact. I went with 36 instead of the classic 64 or 62 ([a-zA-Z0-9]
) because some systems do not care about the case or do not deal with 'special characters'.This leads to these changes:
20171228094721267400000004
becomesp1o0ix4
20171228094721267400010000
becomesp1o0ixcra
Notes
9 < a
).0
), for examplep1o0ix4
is the 4th object created,p1o0ix5
is the 5th one andp1o0ix40
is the 144th, ordering alphabetically will show the order p1o0ix4, p1o0ix40, p1o0ix5p1o0ix
, the next move will be at1000000
which is2176782336
in base 10 or on the 24th of December 2038 (the following one being in the year 4453).jbqb2lgo
which moves the next order of magnitude change to100000000
which is2821109907456
base 10 which is the 25th of May 2059. I'm not sure that the minor inconvenience of not being able to sort warrants the extra length, but for two characters it isn't the end of the world either.Tools: