Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Reading credentials from AWS secret manager into python how to handle the dictionary which is sent as a string

I am fetching secrets from AWS secret manager in my notebook.

I get an output as follows in the jupyter notebook:

{
'SecretString':'{"username":"User1","password":"Pass1"}'
}

I want to parse this to store the variables as

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

username='User1`
password='Pass1'

How do I achieve this? Thanks!

>Solution :

If you’re using python, json.loads should be able to load the message as a dictionary. Then you can call the specific values through the keys, to set as variables. Make sure your the message returned is save in some variable.

 import json
 dic = json.loads(message)
 var1 = dic['Secret String']['var1']
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading