aws: add example of querying secrets manager in python
This commit is contained in:
parent
4505dcd8fd
commit
3ef147c0df
1 changed files with 13 additions and 3 deletions
|
@ -32,8 +32,18 @@ type SomeCredentials = {
|
|||
};
|
||||
```
|
||||
|
||||
// TODO: Add example of deferring to local env var
|
||||
|
||||
## Python
|
||||
|
||||
// TODO: Add Python example
|
||||
```py
|
||||
import json
|
||||
import boto3
|
||||
|
||||
def get_secret():
|
||||
python_env = os.environ.get("PYTHON_ENV", "local")
|
||||
"""In production, source creds from SecretsManager"""
|
||||
if python_env == "production":
|
||||
secrets_manager = boto3.client("secretsmanager")
|
||||
response = secrets_manager.get_secret_value(SecretId=os.environ["SECRET_ARN"])
|
||||
secret_values = json.loads(response["SecretString"])
|
||||
return secret_values["GOOGLE_CREDS"]
|
||||
```
|
||||
|
|
Loading…
Add table
Reference in a new issue