Brightspace / bmx

IAM-less AWS API access for humans.
Apache License 2.0
9 stars 5 forks source link

Support refresh (by default, with opt-out) for print and write #179

Open dougmoscrop opened 5 years ago

dougmoscrop commented 5 years ago

bmx renew did not survive the rewrite from python to golang I think it would be useful to support it.

Example:

bmx renew --profile=test-foo

Renew would:

--profile would default to $AWS_PROFILE if unspecified, allowing users to export AWS_PROFILE=xyz and just bmx renew (all bmx commands should understand and respect AWS_PROFILE in my opinion). I would also argue that renew should be a profile-only command, and I actually completely discourage using default credentials anywhere

chris-redekop commented 5 years ago

From your description, I think a --refresh option on both write and print would make sense and be useful. Did I get that right?

dougmoscrop commented 5 years ago

Yeah, although I think further to your point, --refresh should just be the default behaviour!

Or said, "As a developer, I want to type as few things as possible" 😆

bmx [write|print] should:

  1. take $AWS_PROFILE if set
  2. override that with --profile when provided and fall back to 'default' profile if AWS_PROFILE and --profile are not provided
  3. look to see what account/role was used for {resolved-profile}, if profile is being specified
  4. see if the credentials are expired, and refresh them if necessary, this should only prompt for account/role if default profile was used, or no pre-existing profile-to-account-and-role mapping exists, or --no-refresh is set
  5. write or print them depending on the command

In order to make switching roles possible via interactive prompts, the refresh flag should default to true, but be able to be disabled bmx print --no-refresh would stop at 3. and just act like it currently does (selection for account, role, etc.)