SecretManagerSecret

A Secret Manager secret resource.

This creates the container for the secret and allows you to access the secret's value. You will need to manually add a value to the secret.

Like all Resources, this class configures itself across multiple Environments.

For more information see the official documentation.

Example Usage

1
import launchflow as lf
2
3
# Automatically configures a SecretManager Secret in your GCP project
4
api_key = lf.gcp.SecretManagerSecret("api-key")
5
# Get the latest version of the secret
6
value = secret.version()

initialization

Create a new Secret Manager secret resource.

Args:

  • name (str): The name of the secret.

inputs

1
SecretManagerSecret.inputs(environment_state: EnvironmentState) -> SecretManagerInputs

Get the inputs for the Secret Manager secret resource.

Args:

  • environment_state (EnvironmentState): The environment state to get the inputs for.

Returns:

  • SecretManagerInputs: The inputs for the Secret Manager secret resource.

version

1
SecretManagerSecret.version(version: str = "latest", use_cache: bool = False) -> bytes

Access a version of the secret.

Args:

  • version (str): The version of the secret to access. Defaults to "latest".
  • use_cache (bool): Whether to cache the value of the secret in memory. Defaults to False.

Returns:

  • The value of the secret as bytes.

Example usage:

1
import launchflow as lf
2
3
api_key = lf.gcp.SecretManagerSecret("api-key")
4
secret = api_key.version()

add_version

1
SecretManagerSecret.add_version(payload: bytes)

Add a version of the secret.

Args:

  • payload (bytes): The payload to add to the secret.

Example usage:

1
import launchflow as lf
2
3
api_key = lf.gcp.SecretManagerSecret("api-key")
4
api_key.add_version(open("api-key.txt", "rb").read())