Skip to content

secrets.aws

get_api_key_from_secret_manager

comet_ml.secrets.aws.get_api_key_from_secret_manager(secret_name: str,
    secret_version: str, aws_region_name: Optional[str] = None,
    aws_profile_name: Optional[str] = None) -> str

Returns a Comet API Key Secret that can be used instead of a clear-text API Key when creating an Experiment or API object. The Comet API Key Secret is a string that represents the location of the secret in the AWS Secret Manager without containing the API Key. This means get_api_key_from_secret_manager doesn't need permission or access to AWS Secret Manager.

Args:

  • secret_name: str (required) AWS secret name.
  • secret_version: str (optional) AWS secret version. You can get this value from the store_api_key_in_secret_manager output. You can also pass "latest", in that case the function will return a Comet API Key Secret pointing to the latest version of the AWS Secret.
  • aws_region_name: str (optional) AWS region name. If not specified the default region name from the local AWS configuration will be used.
  • aws_profile_name: str (optional) AWS profile name. If not specified the default profile name from the local AWS configuration will be used.

Example:

api_key = get_api_key_from_secret_manager(
    AWS_SECRET_NAME, aws_region_name="us-east-1" ,aws_profile_name="dev"
)
experiment = comet_ml.Experiment(api_key=api_key)

Returns: (str) Comet API Key Secret.

store_api_key_in_secret_manager

comet_ml.secrets.aws.store_api_key_in_secret_manager(api_key: str,
    secret_name: str, aws_region_name: Optional[str] = None,
    aws_profile_name: Optional[str] = None) -> Tuple[str, str]

Stores an API key to AWS Secret Manager as a secret. After that returns an API Key Secret and AWS Secret version as a string.

Args:

  • api_key: str (required), Comet API to save
  • secret_name: str (required) AWS secret name.
  • aws_region_name: str (optional) AWS region name. If not specified the default region name from the local AWS configuration will be used.
  • aws_profile_name: str (optional) AWS profile name. If not specified the default profile name from the local AWS configuration will be used

Example:

api_key_secret, secret_version = store_api_key_in_secret_manager(
    COMET_API_KEY, AWS_SECRET_NAME
)
experiment = comet_ml.Experiment(api_key=api_key_secret)

Returns: (Tuple[str, str]) API Key Secret, AWS Secret version

Mar. 27, 2024