feat: add workload identity federation support for AWS ECS tasks (#496)#674
Open
cy-yun wants to merge 1 commit into
Open
feat: add workload identity federation support for AWS ECS tasks (#496)#674cy-yun wants to merge 1 commit into
cy-yun wants to merge 1 commit into
Conversation
54fe56d to
06f782a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add support for AWS ECS (Elastic Container Service) credentials in AwsNativeSource
Description
This PR introduces native support for retrieving AWS credentials from the ECS Container Metadata endpoint within
AwsNativeSource.Previously, when running applications inside an Amazon ECS or AWS Fargate container with IAM Roles for Tasks configured, the library could not automatically resolve the temporary container credentials, as it primarily supported EC2 IMDSv2 metadata endpoints, explicit credentials via URLs, or static environment variables (
AWS_ACCESS_KEY_ID, etc).With this change,
AwsNativeSourcenatively honors standard AWS ECS environment variables:AWS_CONTAINER_CREDENTIALS_RELATIVE_URIAWS_CONTAINER_CREDENTIALS_FULL_URIAWS_CONTAINER_AUTHORIZATION_TOKENAWS_CONTAINER_AUTHORIZATION_TOKEN_FILEWhen detected, the library fetches the temporary
AccessKeyId,SecretAccessKey, andTokenfrom the ECS metadata server, allowing seamless workload identity federation between AWS ECS/Fargate and Google Cloud.Changes Made
AwsNativeSource::getSigningVarsFromEcsto probe and execute HTTP requests to the ECS container metadata endpoint.AWS_CONTAINER_AUTHORIZATION_TOKENandAWS_CONTAINER_AUTHORIZATION_TOKEN_FILE).getSigningVarsFromEcsinto the credential resolution fallback chain (after Env variables, but before generic URLs).AwsNativeSourceTestfor both relative and full URI resolutions, as well as token/file variations.How the Customer Uses It
Customers do not need to change any application code.
When a PHP application using
google/authis deployed on Amazon ECS or AWS Fargate with a Task IAM Role assigned, the flow works automatically:GOOGLE_APPLICATION_CREDENTIALSenvironment variable to point to this JSON file in their container.AWS_CONTAINER_CREDENTIALS_RELATIVE_URIenvironment variable into the running container implicitly.GetCallerIdentityrequest, and exchanges it securely for a Google Cloud token.