Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of changes:
Motivation
This CLI tool previously defaulted to using the
default
AWS profile and allowed the user to override that by passing a--profile
option.However, the AWS CLI and other tools will respect the
AWS_PROFILE
environment variable as well. This can be observed in documentation here:https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-using-profiles
To bring consistency with other tools and workflows and convenience for existing users of the environment variable, support for that env variable would be appreciated.
Implementation
Commander natively supports using environment variables as inputs for options. An example can be seen here:
https://github.com/tj/commander.js/blob/master/examples/options-env.js
However, the fluent
.option
method doesn't support setting that configuration. An instance of theOption
class has to be created to set that. The diff required here is fairly small:Impact
This change updates the command definition to support a value from that environment variable as well. The order of precedence is as follows:
--profile
option.AWS_PROFILE
environment variable.AWS_PROFILE
is not set, use"default"
If the user does not have the
AWS_PROFILE
environment variable set, then there is no user-facing impact or change at all.After this change, this is what the help output looks like:
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
No test setup exists in the package, so tests were not added.