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

// DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
import { Construct } from "constructs";
import { TerraformStack } from "cdktf";
/*
 * Provider bindings are generated by running `cdktf get`.
 * See https://cdk.tf/provider-generation for more details.
 */
import { KeyVaultSecret } from "./.gen/providers/azurerm/key-vault-secret";
import { Bytes } from "./.gen/providers/random/bytes";
class MyConvertedCode extends TerraformStack {
  constructor(scope: Construct, name: string) {
    super(scope, name);
    /*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
    For a more precise conversion please use the --provider flag in convert.*/
    const jwtSecret = new Bytes(this, "jwt_secret", {
      length: 64,
    });
    const azurermKeyVaultSecretJwtSecret = new KeyVaultSecret(
      this,
      "jwt_secret_1",
      {
        key_vault_id: "some-azure-key-vault-id",
        name: "JwtSecret",
        value: jwtSecret.base64,
      }
    );
    /*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
    azurermKeyVaultSecretJwtSecret.overrideLogicalId("jwt_secret");
  }
}

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