github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/uuid.html.md (about)

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