I have made a backup database script where my PostgreSQL password is hardcoded.
This script is stored in git and may be open sourced some day.
AWS experts: do you have a better way to deal with passwords?
Related discussions:
I have made a backup database script where my PostgreSQL password is hardcoded.
This script is stored in git and may be open sourced some day.
AWS experts: do you have a better way to deal with passwords?
Related discussions:
SSM Parameter Store
Use SSM Parameter Store: store passwords in there, give your EC2 Instances the correct role to read the parameters they need.
Quick intro: https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-paramstore-cli.html
Use Postgres environment variables: https://www.postgresql.org/docs/9.1/static/libpq-envars.html
Thanks, this is a neat way dealing with sensitive info. Now it’s time to get rid of the hardcoding.
I’m having a little trouble reading out the password:
PROMPT> aws ssm get-parameter --name “/dir0/dir1/dir2/password” --with-decryption
usage: aws [options] [ …] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: argument operation: Invalid choice, valid choices are:
add-tags-to-resource | cancel-command
create-activation | create-association
create-association-batch | create-document
delete-activation | delete-association
delete-document | deregister-managed-instance
describe-activations | describe-association
describe-document | describe-document-permission
describe-instance-information | get-document
list-associations | list-command-invocations
list-commands | list-documents
list-tags-for-resource | modify-document-permission
remove-tags-from-resource | send-command
update-association-status | update-managed-instance-role
help
PROMPT> uname -a
Linux ip-256-256-256-256 4.4.0-1052-aws #61-Ubuntu SMP Mon Feb 12 23:05:58 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
PROMPT> aws --version
aws-cli/1.11.13 Python/3.5.2 Linux/4.4.0-1052-aws botocore/1.4.70
I tried upgrading aws, but I suspect that I’m somehow still running with an outdated version of aws?
Perhaps it’s Amazon’s way telling me that I don’t have permissions to the Parameter Store?
These previous comments are right…
SSM parameter store is the way to go.
I would also add that you can easily encrypt the data with KMS. I am a big fan of this because it is just so easy and you can use IAM permissions to lock down access to that password. You can use different KMS keys for different passwords/environment/clients etc.
Thank you for this incredible snappy hint. Got me started right away.
/dir0/dir1/dir2/password
Is there a reason you are specifying those different “dirs”? I believe you just need to point it to:
aws ssm get-parameter --name “password” --with-decryption
i run the same version as you and i can access the parameter store. Make sure you give the right policy to your user ec2 (iam → roles → attach policy)
AWS docs: Organizing Parameters into Hierarchies
I’m new to AWS, so I have no idea if people are using hierarchies.
KMS also looks great. I will first check out SSM and maybe investigate KMS closer. Thank you.
I use confd with parameter store as the backend. If you need something really robust.
This looks great. I guess confd will work on the development computer, such as macOS. Neat.
Yep
I personally tag instances to define which passwords to use then based off the tag it’ll download the password from a KMS encrypted s3 bucket.
Edit: though I may have misunderstood the original post, the pw is downloaded to an environmental file which gives the creds for Aurora.
This isn’t related to your posted issue, but I highly recommend the aws-shell
https://github.com/awslabs/aws-shell
it gives you auto-completion for all services as well as server-side suggestions like ec2 instance ids and such. Great tool.
We are not using PostgreSQL but MySQL, hopefully my comment is still valid.
We store our scripts in git so we have to make sure passwords are not stored there. We just either environment variables or the MySQL provided credential store on the disk with the option —login-path.
Our assumption is simple: if someone has access to the host then you are already done for. Doesn’t matter where you store your passwords. Your commands will need to read them eventually. In plain text!
So make sure there are no passwords in your scripts. Then secure your host.
Why are you using passwords over roles? Are there advantages of using passwords? Or limitations of what roles can do?
If you’re referring to using IAM authentication for RDS, this would make me think carefully about using IAM auth for applications in production.
The region we use at work doesn’t have SSM, so we use Credstash.
Credstash encrypts your content with KMS and stores it in DynamoDB.
Maybe I check it out. Thanks