Allow token to be passed as env var along with password #262
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.
I wanted better integration with AWS cli support for external processes so I have made this change to allow 2FA tokens to be passed as an env var too. I tried to follow the patterns for password, but it might need some polish.
This allows me to do:
as part of a script that immediately then runs this tool.
I can then configure AWS cli to use this overall script automatically on expiry:
To make this integrate nicely, I also had to make some extra changes:
Use
console.error
notconsole.log
for all information-only output.Add a single
console.log
to echo out the credentials as JSON at the end.The 2nd point should probably be a flag to switch between the original version (where it writes the credentials file for you) vs. this mode where it merely writes the credentials so as to compose with AWS cli's external process support.
This arguably makes the change do more than one thing so maybe it could be split up or at least have that flag added. I thought it was worth getting feedback before I do any more though.