secrets#

Functions for reading secrets from AWS secrets manager.




Functions#

get_secret_by_id

Fetch an AWS secrets manager secret by its ID.

get_secret_response_by_secret_id

Send a GET secret request with boto3 and return the response.

get_secret_by_id()#

rootski_backend_cdk.common.secrets.get_secret_by_id(secret_id: str, region: Optional[str] = None) str[source]#

Fetch an AWS secrets manager secret by its ID.

Parameters
  • secret_id – ID of the secret to fetch

  • region – AWS region to where the secret should exist

get_secret_response_by_secret_id()#

rootski_backend_cdk.common.secrets.get_secret_response_by_secret_id(secret_id: str, region: Optional[str] = None) Dict[str, Any][source]#

Send a GET secret request with boto3 and return the response.

Parameters

secret_id – the secret ID or ARN of the secret to retrieve

Returns

object of the form

{
    "ARN": "arn:aws:secretsmanager:us-west-2:xxx:secret:my-test-secret-str-k4sx86",
    "Name": "my-test-secret-str",
    "VersionId": "490a3ce1-c3d1-496a-b65e-cde9b8a7631c",
    "SecretString": "test-secret-str",
    "VersionStages": ["AWSCURRENT"],
    "CreatedDate": "datetime.datetime(2021, 2, 26, 21, 35, 32, 273000, tzinfo=tzlocal())",
    "ResponseMetadata":
        {
            "RequestId": "64163213-1f39-430a-9ad2-816983695e51",
            "HTTPStatusCode": 200,
            "HTTPHeaders": {"date": "Sat, 27 Feb 2021 05:56:38 GMT",
            "content-type": "application/x-amz-json-1.1",
            "content-length": "262",
            "connection": "keep-alive",
            "x-amzn-requestid": "64163213-1f39-430a-9ad2-816983695e51"},
            "RetryAttempts": 0
        }
}