---
page_title: uuid - Functions - Configuration Language
description: The uuid function generates a unique id.
---

# `uuid` Function

`uuid` generates UUID-format strings using random bytes.

The function generates a well-understood string representation of a 128-bit value, but the output is not RFC-compliant.

This function produces a new value each time it is called, and so using it
directly in resource arguments will result in spurious diffs. We do not
recommend using the `uuid` function in resource configurations, but it can
be used with care in conjunction with
[the `ignore_changes` lifecycle meta-argument](/terraform/language/meta-arguments/lifecycle#ignore_changes).

In most cases we recommend using [the `random` provider](https://registry.terraform.io/providers/hashicorp/random/latest/docs)
instead, since it allows the one-time generation of random values that are
then retained in the Terraform [state](/terraform/language/state) for use by
future operations. In particular,
[`random_id`](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) can generate results with
equivalent randomness to the `uuid` function.

## Examples

```
> uuid()
b5ee72a3-54dd-c4b8-551c-4bdc0204cedb
```

## Related Functions

* [`uuidv5`](/terraform/language/functions/uuidv5), which generates name-based UUIDs.
