What is Python-3 equivalent of 'ConvertTo-SecureString' that can run on AWS EBS (and does not use Python only as wrapper/powershell as a backend)

Viewed 221

I tested the code below in windows power shell and it works for me/is able to send e-mail using AWS SES email service. But what I am really looking for is a Python-3 equivalent of the code (primarily Python equivalent of 'ConvertTo-SecureString') that'd run as part of a AWS Elasticbeanstalk application. The solutions I came across so far used Python wrappers that'd run the code below in powershell but that won't work for me since I need to run the code on AWS. Any pointers how I can achieve this will be appreciated. Thanks.

$AWS_ACCESS_KEY = "xxx"
$AWS_SECRET_KEY = "xxx"
$SECURE_KEY = $(ConvertTo-SecureString -AsPlainText -String $AWS_SECRET_KEY -Force)
$creds = $(New-Object System.Management.Automation.PSCredential ($AWS_ACCESS_KEY, $SECURE_KEY))
$from = "abc@y.com"
$to = "abc@y.com"
$subject = "test" 
$body = "This is the body"
Send-MailMessage -From $from -To $to -Subject $subject -Body $body -SmtpServer email-smtp.us-east-1.amazonaws.com -Credential $creds -UseSsl -Port 587
1 Answers
Related