The resource random_bytes
generates random bytes that are intended to be used as a secret, or key. Use this in preference to random_id
when the output is considered sensitive, and should not be displayed in the CLI.
This resource does use a cryptographic random number generator.
resource "random_bytes" "jwt_secret" {
length = 64
}
resource "azurerm_key_vault_secret" "jwt_secret" {
key_vault_id = "some-azure-key-vault-id"
name = "JwtSecret"
value = random_bytes.jwt_secret.base64
}
length
(Number) The number of bytes requested. The minimum value for length is 1.keepers
(Map of String) Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.base64
(String, Sensitive) The generated bytes presented in base64 string format.hex
(String, Sensitive) The generated bytes presented in lowercase hexadecimal string format. The length of the encoded string is exactly twice the length
parameter.Import is supported using the following syntax:
# Random bytes can be imported by specifying the value as base64 string.
terraform import random_bytes.basic "8/fu3q+2DcgSJ19i0jZ5Cw=="