`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.
More on Cloud, AWX, Windows and Molecule
`Failed to import the required Python library (botocore and boto3) on web01's Python /usr/bin/python3.`Beginner`[WARNING]: * Failed to parse inventory/aws.yml with auto plugin: inventory source 'inventory/aws.yml' could not be verified by inventory plugin 'amazon.aws.aws_ec2'`IntermediateThe `aws_ec2` inventory parses without errors but returns zero hostsIntermediateDynamic inventory finds the instances, but every host is `UNREACHABLE`IntermediateUsing the SSM connection plugin fails with `SessionManagerPlugin is not found` or hangs on file transferAdvanced`winrm or requests is not installed: No module named 'winrm'`Beginner