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()

Utility Methods

version

1
SecretManagerSecret.version(version: str = "latest") -> bytes

Access a version of the secret.

Args:

  • version (str): The version of the secret to access. Defaults to "latest".

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 (str): 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())