A long build fails at the final step with "denied: Your authorization token has expired. Reauthenticate and try again." when pushing to ECR.

IntermediateTroubleshootingPipeline outages
Answer

Likely causes → ECR login tokens last 12 hours. Either the pipeline logged in at the very start of a long job, the agent reuses a stored ~/.docker/config.json from an old login, or the OIDC/assumed-role session (often 1 hour) expired before the push.

Diagnose → Check when docker login / aws ecr get-login-password ran relative to the push, and check the session duration of the assumed role.

Fix → Log in right before pushing:

aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.ap-south-1.amazonaws.com
docker push 123456789012.dkr.ecr.ap-south-1.amazonaws.com/app:$GIT_SHA

Increase role-duration-seconds if the job needs longer than an hour.

Prevent → Use the amazon-ecr-credential-helper so Docker fetches tokens on demand, and keep auth as the last step before push.

All Real-World Interview questions Roadmap: Interview readiness

More on Pipeline outages