Fetching AWS IAM permissions
Introduction
Working with AWS, you typically has access to an ever-growing number of accounts and it is not advisable to create (IAM) users plus associated access keys in each of them.
Hence, you either work with AWS SSO, federated authentication, or you work with a central landing zone, and from there you assume roles in the account you want to work with.
However, some applications (in this case the Redshift JDBC driver) expects real access keys for a particular profile, in order to make use of temporary database credentials.
A well beloved tool for federated authentication does exist, but if you use native AWS authentication I couldn't find it.
This is a very simple tool that fetches temporary access keys for a particular profile and stores them in your ~/.aws/credentials file. So run the command, and refer to your profile (followed by -tmp).
Usage
Usage is pretty simple, you need to know the (working!) aws profile name for which you want to fetch temporary credentials.
The role_arn is read from the profile and temporary credentials are retrieved, and written to ~/.aws/credentials with the same profile name, followed by -tmp.
$ aws-tmp-keys-fetcher --profile my-profile
Use profile my-profile with role arn:aws:iam::1111111111:role/MY_ROLE_NAME
Enter MFA code for arn:aws:iam::0000000000000:mfa/pietje.puk:
Temporary credentials written to /Users/pietjepuk/.aws/credentials with profile my-profile-tmp
If you want to use the output to set environment variables, you can show the output and if desired use command substition to initialize your shell with it.
$ aws-tmp-keys-fetcher -p my-profile --show
AWS_ACCESS_KEY_ID=XXXXXXXXXXXX
AWS_SECRET_ACCESS_KEY=YYYYYYYYYYYYYYYYYY
AWS_SESSION_TOKEN=ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
# Use command substitution to load these values into your environment
$ $(aws-tmp-keys-fetcher -p my-profile --show)
$ env | grep -i aws
AWS_ACCESS_KEY_ID=XXXXXXXXXXXX
AWS_SECRET_ACCESS_KEY=YYYYYYYYYYYYYYYYYY
AWS_SESSION_TOKEN=ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
or if you want to remove these credentials from your environment:
$ aws-tmp-keys-fetcher --reset
unset AWS_ACCESS_KEY_ID
unset AWS_SECRET_ACCESS_KEY
unset AWS_SESSION_TOKEN
$ $(aws-tmp-keys-fetcher --reset)
Metadata
Release files for aws-tmp-keys-fetcher 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aws-tmp-keys-fetcher-0.0.5.tar.gz | 5.0 kB | Without provenance | Details for aws-tmp-keys-fetcher-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aws_tmp_keys_fetcher-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for aws_tmp_keys_fetcher-0.0.5-py3-none-any.whl |
Total release size: 11.7 kB
Release files / aws-tmp-keys-fetcher-0.0.5.tar.gz
| Download URL | aws-tmp-keys-fetcher-0.0.5.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c690503c189a56ffbec96267cb8f0ae3015b7c8f0f52c4991e1e4bcf587d2c09
|
|
BLAKE2b-256 checksum How to use checksums |
02ae34bd43f99e755e408b5c650eddf8ffc32ab96620ba5eb5f4c92ed415779f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.8.3 Darwin/20.6.0
|
Release files / aws_tmp_keys_fetcher-0.0.5-py3-none-any.whl
| Download URL | aws_tmp_keys_fetcher-0.0.5-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d14e2b8ca7b5cf9ae85e7a34cecc9913bc8f758391c29f30e4b4787e99fd2099
|
|
BLAKE2b-256 checksum How to use checksums |
a0397bd82787bd5d1ece8abdf14a36a8b5b25bea936dc9e32d53655c722e82d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.8.3 Darwin/20.6.0
|
Security for aws-tmp-keys-fetcher 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.