Interview Prep/Ansible/Cloud, AWX, Windows and Molecule

`Failed to describe instances: An error occurred (UnauthorizedOperation) when calling the DescribeInstances operation` or `(ExpiredToken)`

IntermediateTroubleshootingCloud, AWX, Windows and Molecule
Answer

Likely causes → The IAM identity lacks ec2:DescribeInstances (and ec2:DescribeRegions if regions is not set), an SSO or STS session expired, or the controller is picking up stale keys from ~/.aws/credentials before its instance role.

Diagnose →

aws sts get-caller-identity
env | grep ^AWS_

Fix → Grant read-only EC2 describe permissions to the automation role, refresh the session (aws sso login --profile prod), or remove the stale static keys so the instance or IRSA role is used.

Prevent → In CI and AWX, use short-lived role credentials (OIDC to AWS, instance profiles, IRSA) instead of static access keys.

All Ansible questions Roadmap: Ansible

More on Cloud, AWX, Windows and Molecule