2020-12-19 00:46:30 +01:00
|
|
|
---
|
2021-12-15 03:41:17 +01:00
|
|
|
page_title: sensitive - Functions - Configuration Language
|
|
|
|
description: The sensitive function marks a value as being sensitive.
|
2020-12-19 00:46:30 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
# `sensitive` Function
|
|
|
|
|
2021-05-14 18:27:13 +02:00
|
|
|
-> **Note:** This function is only available in Terraform v0.15 and later.
|
2020-12-19 00:46:30 +01:00
|
|
|
|
|
|
|
`sensitive` takes any value and returns a copy of it marked so that Terraform
|
|
|
|
will treat it as sensitive, with the same meaning and behavior as for
|
2021-12-15 03:41:17 +01:00
|
|
|
[sensitive input variables](/language/values/variables#suppressing-values-in-cli-output).
|
2020-12-19 00:46:30 +01:00
|
|
|
|
2021-05-14 18:27:13 +02:00
|
|
|
Wherever possible we recommend marking your input variable and/or output value
|
|
|
|
declarations as sensitive directly, instead of using this function, because in
|
|
|
|
that case you can be sure that there is no way to refer to those values without
|
|
|
|
Terraform automatically considering them as sensitive.
|
2020-12-19 00:46:30 +01:00
|
|
|
|
|
|
|
The `sensitive` function might be useful in some less-common situations where a
|
2021-05-14 18:27:13 +02:00
|
|
|
sensitive value arises from a definition _within_ your module, such as if you've
|
|
|
|
loaded sensitive data from a file on disk as part of your configuration:
|
2020-12-19 00:46:30 +01:00
|
|
|
|
|
|
|
```
|
|
|
|
locals {
|
|
|
|
sensitive_content = sensitive(file("${path.module}/sensitive.txt"))
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
However, we generally don't recommend writing sensitive values directly within
|
|
|
|
your module any of the files you distribute statically as part of that module,
|
|
|
|
because they may be exposed in other ways outside of Terraform's control.
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
```
|
|
|
|
> sensitive(1)
|
|
|
|
(sensitive)
|
|
|
|
> sensitive("hello")
|
|
|
|
(sensitive)
|
|
|
|
> sensitive([])
|
|
|
|
(sensitive)
|
|
|
|
```
|