Current Terraform Version
Use-cases
Run terraform in a pod inside a EKS cluster with a IAM role assigned to the service account , leveraging the AssumeRoleWithWebIdentity API.
https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts-technical-overview.html
Attempted Solutions
Inside the pod, aws sts get-caller-identity is using the correct role, but terraform fallback to the instance profile role.
AssumeRoleWithWebIdentity support was added to aws-sdk-go since 1.23.13.
Proposal
Terraform should try using AssumeRoleWithWebIdentity before EC2