Amazon AWS - Secrets Manager¶
Nothing can be simpler to interact with Secret Keys than the BotCity plugin for AWS Secrets Manager.
Manage your credentials.
Installation¶
Importing the Plugin¶
After you installed this package, the next step is to import the package into your code and start using the functions.
Setting up connection¶
Note
There are two different ways to authenticate.
1. Creating the .aws
folder in the home directory, you need to create two files.
# ~/.aws/credentials
[default]
aws_access_key_id=<your_aws_access_key_id>
aws_secret_access_key=<your_aws_secret_access_key>
2. Passing credentials in the class constructor.
# Using the `.aws` folder
secrets = BotSecretsManagerPlugin()
# Alternative using the credentials as constructor arguments
secrets = BotSecretsManagerPlugin(
use_credentials_file=False,
access_key_id='<your_aws_access_key_id>',
secret_access_key='<your_aws_secret_access_key>',
region_name='<region_code>'
)
Info: If not found secret
Some methods return None
if they don't find the secret, if you want to receive the error and handle it use RAISE_IF_NOT_FOUND=True
Secrets operations¶
Create new secret¶
from botcity.plugins.aws.secretsmanager import BotSecretsManagerPlugin
secret = BotSecretsManagerPlugin()
response = secret.create_secret(
secret_name='test',
secret_value={'key': 'name'}, # dict or str
description='Test description.')
print(response)
# Or
secret["test"] = {'key': 'name'} # description=''
List secrets¶
Retrieves secret info¶
Retrieve secret value¶
Update secret value¶
Delete secret¶
Warning
If you delete a secret with the without_recovery=True
parameter, then you have no opportunity to recover the secret. You lose the secret permanently.