2018-05-13 22:48:45 +02:00
|
|
|
---
|
|
|
|
layout: "functions"
|
2018-12-20 05:35:11 +01:00
|
|
|
page_title: "uuid - Functions - Configuration Language"
|
2018-05-13 22:48:45 +02:00
|
|
|
sidebar_current: "docs-funcs-crypto-uuid"
|
|
|
|
description: |-
|
|
|
|
The uuid function generates a unique id.
|
|
|
|
---
|
|
|
|
|
|
|
|
# `uuid` Function
|
|
|
|
|
2019-01-17 01:33:57 +01:00
|
|
|
-> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and
|
|
|
|
earlier, see
|
|
|
|
[0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html).
|
|
|
|
|
2018-05-13 22:48:45 +02:00
|
|
|
`uuid` generates a unique identifier string.
|
|
|
|
|
|
|
|
The id is a generated and formatted as required by
|
|
|
|
[RFC 4122 section 4.4](https://tools.ietf.org/html/rfc4122#section-4.4),
|
|
|
|
producing a Version 4 UUID. The result is a UUID generated only from
|
|
|
|
pseudo-random numbers.
|
|
|
|
|
|
|
|
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
|
2019-03-01 01:15:20 +01:00
|
|
|
[the `ignore_changes` lifecycle meta-argument](../resources.html#ignore_changes).
|
2018-05-13 22:48:45 +02:00
|
|
|
|
|
|
|
In most cases we recommend using [the `random` provider](/docs/providers/random/index.html)
|
|
|
|
instead, since it allows the one-time generation of random values that are
|
|
|
|
then retained in the Terraform [state](/docs/state/index.html) for use by
|
|
|
|
future operations. In particular,
|
|
|
|
[`random_id`](/docs/providers/random/r/id.html) can generate results with
|
|
|
|
equivalent randomness to the `uuid` function.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
```
|
|
|
|
> uuid()
|
|
|
|
b5ee72a3-54dd-c4b8-551c-4bdc0204cedb
|
|
|
|
```
|
2019-05-08 11:13:30 +02:00
|
|
|
|
|
|
|
## Related Functions
|
|
|
|
|
|
|
|
* [`uuidv5`](./uuidv5.html), which generates name-based UUIDs.
|