aramalipoor / aws-cost-saver

A tiny CLI tool to help save costs in development environments when you're asleep and don't need them!
MIT License
305 stars 9 forks source link

Add Support for environment variables to configure credentials #16

Closed quickliketurtle closed 4 years ago

quickliketurtle commented 4 years ago

Hello, I'd like to suggest adding support for environment variables for profile, access key id, secret access key, default region, etc. replicating what the AWS cli and SDK's support.

I'm happy to contribute as well but wanted to see your interest first. :-)

aramalipoor commented 4 years ago

Hi @quickliketurtle :)

Thanks for the suggestion, actually you can provide credentials via env variables:

export AWS_ACCESS_KEY_ID=xxxxxxxxxxx
export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
export AWS_REGION=eu-central-1

aws-cost-saver conserve --dry-run

Let me know if it doesn't work you.

quickliketurtle commented 4 years ago

Awesome, thanks for the reply. Then the only other thing I was thinking was supporting the exported AWS_PROFILE. My use case is that I don't set a 'default' profile since I work on a bunch of accounts... So on specific projects i export AWS_PROFILE=clientproject1...

aramalipoor commented 4 years ago

@quickliketurtle you can specify profile by -p|--profile flag but I don't think there's any point of providing "profile" if you provide credentials via AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY 🤔

aws-cost-saver conserve --dry-run --profile my-other-profile

Useful quote from AWS docs:

Security credentials are account-specific. If you have access to multiple AWS accounts, you have separate credentials for each account. https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html

quickliketurtle commented 4 years ago

Ok, would just fix my current workflow with other tools like aws cli, serverless framework, etc... If it's not useful to others, no need to add it... Thanks for talking it through. :-)

aramalipoor commented 4 years ago

Cool, let me know if had any issues managing multiple client accounts :)