github.com/hugorut/terraform@v1.1.3/website/docs/language/functions/uuid.mdx (about) 1 --- 2 page_title: uuid - Functions - Configuration Language 3 description: The uuid function generates a unique id. 4 --- 5 6 # `uuid` Function 7 8 `uuid` generates a unique identifier string. 9 10 The id is a generated and formatted as required by 11 [RFC 4122 section 4.4](https://tools.ietf.org/html/rfc4122#section-4.4), 12 producing a Version 4 UUID. The result is a UUID generated only from 13 pseudo-random numbers. 14 15 This function produces a new value each time it is called, and so using it 16 directly in resource arguments will result in spurious diffs. We do not 17 recommend using the `uuid` function in resource configurations, but it can 18 be used with care in conjunction with 19 [the `ignore_changes` lifecycle meta-argument](/language/meta-arguments/lifecycle#ignore_changes). 20 21 In most cases we recommend using [the `random` provider](https://registry.terraform.io/providers/hashicorp/random/latest/docs) 22 instead, since it allows the one-time generation of random values that are 23 then retained in the Terraform [state](/language/state) for use by 24 future operations. In particular, 25 [`random_id`](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) can generate results with 26 equivalent randomness to the `uuid` function. 27 28 ## Examples 29 30 ``` 31 > uuid() 32 b5ee72a3-54dd-c4b8-551c-4bdc0204cedb 33 ``` 34 35 ## Related Functions 36 37 * [`uuidv5`](/language/functions/uuidv5), which generates name-based UUIDs.