Context manager for AWS Profiles
NOTE: jq required
:arrow_down: Download a binary and move to /usr/local/bin
console
$ curl -s https://api.github.com/repos/hiro-o918/awsctx/releases/latest \
| jq -r '.assets[] | select(.name | test("^awsctx_v[0-9]+\\.[0-9]+\\.[0-9]+_x86_64-apple-darwin\\.tar\\.gz$")) | .browser_download_url' \
| xargs wget -O - \
| tar zxvf - \
&& mv awsctx /usr/local/bin
:arrow_down: Download a binary and move to /usr/local/bin
console
$ curl -s https://api.github.com/repos/hiro-o918/awsctx/releases/latest \
| jq -r '.assets[] | select(.name | test("^awsctx_v[0-9]+\\.[0-9]+\\.[0-9]+_x86_64-unknown-linux-musl\\.tar\\.gz$")) | .browser_download_url' \
| xargs wget -O - \
| tar zxvf - \
&& mv awsctx /usr/local/bin
Authorize your shell by some ways with specified profile name.
Then, you get ~/.aws/credentials
like
```
[foo]
awsaccesskeyid = XXXXXXXXXXX
awssecretaccesskey = XXXXXXXXXXX
awssessiontoken = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[bar] awsaccesskeyid = YYYYYYYYYYY awssecretaccesskey = YYYYYYYYYYY awssessiontoken = YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY ```
use-context
update ~/.aws/credentials
to contain default
profile that the values are same as specified in the option.
console
$ awsctx use-context -p foo
e.g. the above commands updates credentials as the below.
```
[foo]
awsaccesskeyid = XXXXXXXXXXX
awssecretaccesskey = XXXXXXXXXXX
awssessiontoken = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[bar] awsaccesskeyid = YYYYYYYYYYY awssecretaccesskey = YYYYYYYYYYY awssessiontoken = YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
[default] awsaccesskeyid = XXXXXXXXXXX awssecretaccesskey = XXXXXXXXXXX awssessiontoken = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ```