How to Generate a Random Number/String in Terraform

If you need to generate a random number or string in Terraform, then you can use the following:

resource "random_id" "myrandom" { keepers = { first = "${timestamp()}" } byte_length = 8 }
Code language: plaintext (plaintext)

Then refer to it as:

random_id.myrandom.hex
Code language: plaintext (plaintext)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments