I have a flask app hosted on Heroku that needs to run commands on an AWS EC2 instance (Amazon Linux AMI) using boto.cmdshell. A couple of questions:
- Is using a key pair to access the EC2 instance the best practice? Or is using username/password better?
- If using a key pair is the preferred method, what’s the best practice on managing/storing private keys on Heroku? Obviously putting the private key in git is not an option.
Thanks.
What I was looking for was guidance on how to deal with private keys. Both @DrewV and @yfeldblum pointed me to the right direction. I ended up turning my private key into a string and storing it in a Heroku config variables.
If anyone is looking to do something similar, here’s a sample code snippit using paramiko:
Thanks to @DrewV and @yfeldblum for helping (upvote for both).