random_bytes (Resource)

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.

Example Usage

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
}

Schema

Required

Optional

Read-Only

Import

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=="