donnemartin/saws

Support for --region and --profile

pnewb opened this issue · 11 comments

pnewb commented

The AWS config file allows for multiple profiles and specifying a particular region if you're in more than one. This allows for having a single configuration file which holds credentials for multiple AWS accounts.

As I've got the [default] entry disabled by default, saws wouldn't function properly. At the moment I've set a particular profile and region as a default just to play around, and it looks pretty nice, but being able to specify profile and region when launching saws would be hugely helpful. (Alternately, if the functionality exists, and I just couldn't figure it out...my apologies.)

I'd love to see this support also. You can split the profile into .aws/credentials and .aws/config allowing people in a company with very many accounts to share the config but not the credentials.

Great suggestion! Currently you'd have to specify region or profile like the following:

being able to specify profile and region when launching saws would be hugely helpful.

I agree, I think supporting a config for region and profile in ~/.sawsrc would do the trick.

pnewb commented

What first came to my mind was more of:
saws --profile development --region us-west-2
and then all further commands would append those by default.

As mattford63 mentioned, you can have the profiles (along with default regions per profile making the --region flag truly optional) in ~/.aws/config where many other tools expect them. You'd be falling closer in line with existing convention, at least in my limited experience.

saws --profile development --region us-west-2

Thanks for clarifying!

You can also set the environment variable AWS_DEFAULT_PROFILE, meaning you no longer have to specify the profile for every command.

I found this works

AWS_PROFILE=myprofile saws

Thanks for sharing @bashtoni and @djhworld.

In the meantime, I'll update the README installation section:

AWS Credentials and Named Profiles

Configure your credentials with the AWS CLI:

$ aws configure

If you'd like to use a specific named profile with SAWS, run the following commands on OS X, Linux, or Unix:

$ export AWS_DEFAULT_PROFILE=user1
$ saws

Or as a one-liner:

$ AWS_DEFAULT_PROFILE=user1 saws

Windows users can run the following commands:

> set AWS_DEFAULT_PROFILE=user1
> saws

Command line options for starting SAWS with a specific profile are under development.

For more details on how to install and configure the AWS CLI, refer to the following documentation.

+1

I'm using 0.4.3, have my region set in an environment variable and profile, and while it's using the correct version it still says You must specify a region. You can also configure your region by running "aws configure". every time I refresh with F5. Not sure if it's a big deal, but it should reflect that my region is set. Everything else I'm using is picking it up, maybe I'm missing something?

@donnemartin

Could we have the feature as

saws --profile development --region us-west-2

more than export the aws profile?