-
Notifications
You must be signed in to change notification settings - Fork 42
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
Conversation
e21bd29
to
a2b3c0f
Compare
a2b3c0f
to
ae95142
Compare
ae95142
to
f8275c9
Compare
There was a problem hiding this 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
There was a problem hiding this 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)
b8681d6
to
ab1dd2a
Compare
Can we please not rebase PRs after review, I will now have to do a fresh review on this PR.
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 |
@tustvold I changed to
My understanding from the README doc is that entire feature |
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 |
thanks @tustvold |
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?
New Config Keys
Adds
AmazonS3ConfigKey::ContainerCredentialsFullUri
andAmazonS3ConfigKey::ContainerAuthorizationTokenFile
to the config-based approach, for parsing EKS Pod Identity settings. The builder picks these keys from environment variablesAWS_CONTAINER_CREDENTIALS_FULL_URI
andAWS_CONTAINER_AUTHORIZATION_TOKEN_FILE
.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.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 infrom_env
or direct calls towith_config
, falling back to ECS or instance metadata if EKS variables are absent.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
andAWS_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.