flip_api.utils.get_secrets

Functions

get_secrets(→ dict)

Retrieve secrets from AWS Secrets Manager.

get_secret(→ str)

Retrieve a specific secret value from an AWS Secrets Manager secret.

Module Contents

flip_api.utils.get_secrets.get_secrets(secret_name: str = '', region_name: str = '') dict

Retrieve secrets from AWS Secrets Manager.

Parameters:
  • secret_name (str) – The name of the secret to retrieve.

  • region_name (str) – The AWS region where the secret is stored.

Returns:

The retrieved secret as a dictionary.

Return type:

dict

Raises:
  • ClientError – If the AWS Secrets Manager API call fails.

  • ValueError – If the secret does not contain a SecretString, is not valid JSON, or is not a JSON object.

flip_api.utils.get_secrets.get_secret(secret_key: str, secret_name: str = '', region_name: str = '') str

Retrieve a specific secret value from an AWS Secrets Manager secret.

Parameters:
  • secret_key (str) – The key of the secret to retrieve.

  • secret_name (str) – The name of the secret to retrieve.

  • region_name (str) – The AWS region where the secret is stored.

Returns:

The value of the requested secret.

Return type:

str

Raises:
  • KeyError – If secret_key is not present in the retrieved secret.

  • ClientError – If the AWS Secrets Manager API call fails.

  • ValueError – If the secret payload is malformed (see get_secrets()).