Simplify the process of AWS CLI token refresh with this guide, I explain the maual process and then, provide a Python automated script that makes life so easier to refresh AWS CLI tokens for jobs (github actions and so on). The script is always up to date so it can be used any time. Also anyone can contribute to it.
A comprehensive guide to effortlessly manage and refresh AWS CLI tokens, ensuring smooth operations with both manual and automated methods.
AWS access tokens often expire within hours, compelling users to constantly refresh them. If you are new to it, that is HELL!!. To avoid this pain, this script helps you refresh your tokens via your aws profile name save on your device.
Check Token Status:
aws sts get-caller-identity --profile <profile-name>
Checks if the current token session has expired.
Refresh Token:
aws configure sso
Follow prompts to input necessary credentials and renew the token. (the problem with this is that it will refresh the token and save it into the cli cache without refreshing the credentials one.
This is annoying because it involves some copy and paste again and again. The automation script just refresh everything that is needed. Then if you want you can take then the script and modify to automate it (for example to run it each x hours and take automatically send the return values somewhere. Here, the script just refresh everything in one click on your device. So it is really flexible.)
Run the Python script:
script.py --profile <profile-name> # example script.py --profile admin-1
Automates the refresh process using the saved profile configuration.
This guide is an essential resource for developers and engineers who need a reliable way to manage AWS CLI tokens. Enhance AWS workflows by seamlessly integrating the methods outlined in this guide.
No comments yet.
Sign in to be the first to comment.