Problem:
When authenticating to AWS, you may run into an issue where the error Your authorization
token has expired
is being returned. This issue can arise when stale credentials are being used for authentication.
Solutions:
- Solution - Removing cached configuration files
-
Two likely sources of this error are the Docker
config.json
and/or AWScredentials
files when cached or persisted on a self-hosted runner.You can add run the following code snippet at the beginning of your job to remove these files.
- run: name: Remove config and credential files command: | if [ -f "$HOME/.docker/config.json" ]; then rm -f ~/.docker/config.json fi if [ -f "$HOME/.aws/credentials" ]; then rm -f ~/.aws/credentials fi
Following that, you can then proceed to authenticate by using a command such as the aws-ecr orb's
ecr-login
command.
-
Outcome:
The stored credentials will be cleared, and you can then authenticate via the aws cli with the correct credentials.
Comments
Article is closed for comments.