Created
April 18, 2020 10:10
-
-
Save vishnuhd/670aabdcb60a8c22044241161d3f971f to your computer and use it in GitHub Desktop.
Revisions
-
vishnuhd created this gist
Apr 18, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ import boto3 import os import json filename = 'data.json' kms_id = '' secretdata= {"username":"chris","password":"BnQw!XDWgaEeT9XGTT29"} secret_data={} for k,v in secretdata.items(): encrypt_string = os.popen(("aws kms encrypt --key-id %s --plaintext '%s' --query CiphertextBlob --output text" % (kms_id, v))).read() secret_data[k] = encrypt_string json_data = json.dumps(secret_data) with open(filename,'w') as f: f.write(json_data) with open('data.json', 'r') as content_file: secret_content = content_file.read() print(secret_content) client = boto3.client('secretsmanager') response = client.create_secret( Description='My test secret', Name='MyTestt', SecretString=secret_content, )