Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a --profile option to allow AWS profile selection #73

Open
nk9 opened this issue Jul 2, 2022 · 3 comments
Open

Provide a --profile option to allow AWS profile selection #73

nk9 opened this issue Jul 2, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@nk9
Copy link

nk9 commented Jul 2, 2022

Users with multiple AWS accounts can declare named profiles to manage the different sets of credentials/regions. It would be ideal if s3-credentials accepted a --profile argument, just like the aws comand line tool.

@nk9
Copy link
Author

nk9 commented Jul 2, 2022

It looks like this functionality is mostly there when setting AWS_PROFILE. However, I still had to pass the --bucket-region parameter even though I've declared the default region in ~/.aws/config. It would be great to have the profile natively understood by the tool so that could be skipped.

$ cat ~/.aws/credentials
[personal]
aws_access_key_id = ABCD
aws_secret_access_key = EFg+H
$ cat ~/.aws/config
[profile personal]
region = eu-west-2
$ AWS_PROFILE=personal s3-credentials create s3-project --bucket-region eu-west-2 --statement '{
  "Effect": "Allow",
  "Action": "textract:*",
  "Resource": "*"
}' --create-bucket > ocr.json

@simonw simonw added the enhancement New feature or request label Jul 11, 2022
@benkehoe
Copy link

benkehoe commented Nov 15, 2022

More fundamentally, the code should be using boto3 Sessions, rather than creating clients directly (which uses the default session). This makes it simple to add a --profile option as well, since boto3.Session(profile_name=profile) will resolve credentials as normal if profile is None. More details on sessions: https://ben11kehoe.medium.com/boto3-sessions-and-why-you-should-use-them-9b094eb5ca8e

@simonw
Copy link
Owner

simonw commented Nov 16, 2022

Thanks, that's really useful - I think that's what I'd been missing here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants