Skip to main content

snippets_py

Integration

New integration from credential
aws_secrets_manager_client = yepcode.integration.aws_secrets_manager("credential-slug")
New integration from plain authentication data
import boto3

session = boto3.Session(
aws_access_key_id="accessKeyId",
aws_secret_access_key="secretAccessKey",
region_name="region"
)
aws_secrets_manager_client = session.client("secretsmanager")

Create Secret

Create secret
aws_secrets_manager_client.create_secret(
Name="secret-name",
SecretString="secret-value-to-store"
)

List Secrets

List secrets
response = aws_secrets_manager_client.list_secrets()
secrets = response['SecretList']
for secret in secrets:
print(f"Found secret with name {secret['Name']}")

Get Secret Value

Get secret value
response = aws_secrets_manager_client.get_secret_value(
SecretId="secret-name-or-ARN"
)
# Secret value comes in response.SecretString or response.SecretBinary
# If you store other types of secrets different than key value pairs,
# then it will come as a JSON string

Delete Secret

Delete secret
aws_secrets_manager_client.delete_secret(
SecretId="secret-name-or-ARN",
ForceDeleteWithoutRecovery=True
)