feat: Add EKS Pod Identity support to Amazon ECR login action (#624, #735) #740
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue Number:
#624, #735
Overview
This PR adds support for Amazon EKS Pod Identity in the
amazon-ecr-loginGitHub Action. Previously, the action failed when running in an EKS Pod Identity environment because the AWS SDK attempted to use the container metadata service, which resulted in the error:169.254.170.23 is not a valid container metadata service hostname.To address this, we now explicitly detect Pod Identity environments and use
fromHttp()from@aws-sdk/credential-providersto authenticate, ensuring proper credential resolution.Changes
1. Implement Pod Identity detection and authentication
AWS_CONTAINER_CREDENTIALS_FULL_URIis set, we assume Pod Identity is being used.2. Maintain support for IRSA and default authentication
3. Successful Login, Pull, and Push Validation
Tested the new implementation in both Pod Identity and IRSA environments, ensuring that authentication, login, and image push to ECR work as expected.
Test Logs:
✅ Pod Identity Environment
{ "UserId": "AROXXXXXX:eks-cluster-pod-identity", "Account": "123456789012", "Arn": "arn:aws:sts::123456789012:assumed-role/eks-cluster-pod-identity-role/session-id" }fromHttp()authentication✅ IRSA Environment
{ "UserId": "AROYYYYYY:botocore-session", "Account": "123456789012", "Arn": "arn:aws:sts::123456789012:assumed-role/eks-cluster-irsa-role/session-id" }Impact
Workaround Before This PR
Before this PR, users needed a workaround to prevent the action from attempting to use invalid metadata service credentials:
With this PR, the action now correctly detects and uses Pod Identity authentication automatically.
Conclusion
This PR ensures that self-hosted GitHub Actions runners running inside Amazon EKS with Pod Identity can properly authenticate with Amazon ECR without requiring additional configuration.
Would appreciate any feedback, and thanks for reviewing this contribution! 🙌🚀