8000 feat: add EKS Pod Identity support (#282) by andreasbros · Pull Request #333 · apache/arrow-rs-object-store · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add EKS Pod Identity support (#282) #333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2025

Conversation

andreasbros
Copy link
Contributor
@andreasbros andreasbros commented Apr 15, 2025

Which issue does this PR close?

Closes #282

Rationale for this change

This PR extends the AmazonS3Builder so that it recognises and supports EKS Pod Identity credentials using the two environment variables:

  • AWS_CONTAINER_CREDENTIALS_FULL_URI

  • AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE

Previously, the builder only considered ECS task credentials (AWS_CONTAINER_CREDENTIALS_RELATIVE_URI), instance metadata, static credentials, or web identity tokens. Adding EKS Pod Identity support aligns it with modern Kubernetes IRSA setups, allowing pods to retrieve AWS credentials from an EKS endpoint without needing to mount AWS credentials directly.

What changes are included in this PR?

  1. New Config Keys
    Adds AmazonS3ConfigKey::ContainerCredentialsFullUri and AmazonS3ConfigKey::ContainerAuthorizationTokenFile to the config-based approach, for parsing EKS Pod Identity settings. The builder picks these keys from environment variables AWS_CONTAINER_CREDENTIALS_FULL_URI and AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE.

  2. EKSPodCredentialProvider
    Introduces an EKSPodCredentialProvider, which is constructed when both config keys are set. It uses a bearer token (read from the specified file) to fetch short-lived credentials from the EKS credential endpoint.

  3. Builder Logic
    Adjusts AmazonS3Builder::build to give priority to EKS credentials if both the full URI and token file are specified. It checks environment variables in from_env or direct calls to with_config, falling back to ECS or instance metadata if EKS variables are absent.

  4. Tests
    Adds tests to confirm EKS credentials build and provider.

Are there any user-facing changes?

  • New EKS Credential Support
    Users in EKS can now set AWS_CONTAINER_CREDENTIALS_FULL_URI and AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE, and the builder automatically fetches credentials.

  • Configuration Keys
    Two new config keys are recognised by the builder:

    • AmazonS3ConfigKey::ContainerCredentialsFullUri
    • AmazonS3ConfigKey::ContainerAuthorizationTokenFile

These changes are backwards-compatible: existing ECS, static credentials, or IMDS-based setups continue to work unchanged. No additional user steps are required unless they specifically opt to use EKS Pod Identity.

Copy link
Contributor
@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @andreasbros

I am not familiar with this AWS feature, but this PR looks very well commented, tested and follows the existing patterns in the crate. It looks good to me 👏

It seems there is a small error when compiling for wasm that the CI found, but otherwise this PR is good to merge from my perspective

tustvold
tustvold previously approved these changes Apr 21, 2025
Copy link
Contributor
@tustvold tustvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, I think it just needs the WASM build to be fixed (likely by just disabling this functionality on WASM platforms)

@andreasbros andreasbros force-pushed the feat/eks-pod-identity branch from b8681d6 to ab1dd2a Compare April 22, 2025 15:06
@andreasbros
Copy link
Contributor Author

Thanks @alamb and @tustvold for checking, and indeed WASM build was failing, it was because I used async tokio::fs, I now changed it to std::fs and this should resolve the issue, just waiting for GHA workflows to get approved and executed.

@tustvold tustvold dismissed their stale review April 22, 2025 15:19

Force pushed

@tustvold
Copy link
Contributor
tustvold commented Apr 22, 2025

Can we please not rebase PRs after review, I will now have to do a fresh review on this PR.

I now changed it to std::fs

We should use tokio:fs, std::fs shouldn't be used in async contexts (unless wrapped in spawn_blocking, see LocalFilesystem), it just needs to be appropriately gated - WASM contexts don't have filesystem access

@andreasbros
Copy link
Contributor Author
andreasbros commented Apr 22, 2025

@tustvold I changed to std::fs based on existing web_identity implementation, but I agree it should be async ideally:
https://github.com/apache/arrow-rs-object-store/blob/main/src/aws/credential.rs#L639

it just needs to be appropriately gated

My understanding from the README doc is that entire feature aws is not available in WASM.
Can you point me to how to gate it?

@tustvold
Copy link
Contributor
tustvold commented May 3, 2025

I took the liberty of pushing a quick fix to avoid doing blocking IO within the credential provider, using the same trick we use for LocalFilesystem (which is also what tokio::fs does under the hood).

I don't have a means to test this, but if you are happy it is working I'm happy to get this merged

@andreasbros
Copy link
Contributor Author
andreasbros commented May 6, 2025

I took the liberty of pushing a quick fix

thanks @tustvold

@tustvold tustvold merged commit 36752c9 into apache:main May 6, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support EKS Pod Identity (alternative to IRSA)
3 participants
0