pub struct ECSCredentialProvider { /* private fields */ }Expand description
ECS Task Role Credentials Provider
This provider fetches IAM credentials from the ECS Task IAM Roles endpoint. It supports both relative URI (ECS) and full URI (Fargate) modes.
§Important Note
This provider fetches IAM credentials, not task metadata. The credentials endpoint is separate from the task metadata endpoints (v2/v3/v4). While metadata endpoints provide information about the task and container, the credentials endpoint provides IAM role credentials for authentication.
§Configuration
Configuration values can be provided directly via builder methods or through environment variables. Direct configuration takes precedence over environment variables.
§Builder Methods
ECSCredentialProvider::with_relative_uri: Set the relative URI for ECS environmentsECSCredentialProvider::with_endpoint: Set a complete custom endpoint URL (for Fargate or custom setups)ECSCredentialProvider::with_auth_token: Set the authorization token directlyECSCredentialProvider::with_auth_token_file: Set the path to the authorization token fileECSCredentialProvider::with_metadata_uri_override: Override the base metadata endpoint for relative URIs
§Environment Variables (Fallback)
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI: Relative URI to fetch credentials (ECS)AWS_CONTAINER_CREDENTIALS_FULL_URI: Full URI to fetch credentials (Fargate)AWS_CONTAINER_AUTHORIZATION_TOKEN: Authorization token for the requestAWS_CONTAINER_AUTHORIZATION_TOKEN_FILE: File containing the authorization tokenECS_CONTAINER_METADATA_URI: Override the default base endpoint (for testing)
§Examples
use reqsign_aws_core::ECSCredentialProvider;
// Configure for ECS with relative URI
let provider = ECSCredentialProvider::new()
.with_relative_uri("/v2/credentials/task-role")
.with_auth_token("my-auth-token");
// Configure for Fargate with full endpoint
let provider = ECSCredentialProvider::new()
.with_endpoint("http://169.254.170.2/v2/credentials/task-role")
.with_auth_token_file("/tmp/auth-token");Implementations§
Source§impl ECSCredentialProvider
impl ECSCredentialProvider
Sourcepub fn with_endpoint(self, endpoint: impl Into<String>) -> Self
pub fn with_endpoint(self, endpoint: impl Into<String>) -> Self
Create with custom endpoint
Sourcepub fn with_auth_token(self, token: impl Into<String>) -> Self
pub fn with_auth_token(self, token: impl Into<String>) -> Self
Create with custom auth token
Sourcepub fn with_auth_token_file(self, file_path: impl Into<String>) -> Self
pub fn with_auth_token_file(self, file_path: impl Into<String>) -> Self
Create with custom auth token file path
Sourcepub fn with_relative_uri(self, uri: impl Into<String>) -> Self
pub fn with_relative_uri(self, uri: impl Into<String>) -> Self
Create with container credentials relative URI This is used in ECS environments where the base metadata URI is known
Sourcepub fn with_metadata_uri_override(self, uri: impl Into<String>) -> Self
pub fn with_metadata_uri_override(self, uri: impl Into<String>) -> Self
Override the metadata URI base endpoint (typically for testing) Defaults to http://169.254.170.2 if not specified
Trait Implementations§
Source§impl Clone for ECSCredentialProvider
impl Clone for ECSCredentialProvider
Source§fn clone(&self) -> ECSCredentialProvider
fn clone(&self) -> ECSCredentialProvider
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ECSCredentialProvider
impl Debug for ECSCredentialProvider
Source§impl Default for ECSCredentialProvider
impl Default for ECSCredentialProvider
Source§impl ProvideCredential for ECSCredentialProvider
impl ProvideCredential for ECSCredentialProvider
Source§type Credential = Credential
type Credential = Credential
Source§async fn provide_credential(
&self,
ctx: &Context,
) -> Result<Option<Self::Credential>>
async fn provide_credential( &self, ctx: &Context, ) -> Result<Option<Self::Credential>>
Auto Trait Implementations§
impl Freeze for ECSCredentialProvider
impl RefUnwindSafe for ECSCredentialProvider
impl Send for ECSCredentialProvider
impl Sync for ECSCredentialProvider
impl Unpin for ECSCredentialProvider
impl UnsafeUnpin for ECSCredentialProvider
impl UnwindSafe for ECSCredentialProvider
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> ProvideCredentialDyn for Twhere
T: ProvideCredential + ?Sized,
impl<T> ProvideCredentialDyn for Twhere
T: ProvideCredential + ?Sized,
Source§type Credential = <T as ProvideCredential>::Credential
type Credential = <T as ProvideCredential>::Credential
Source§fn provide_credential_dyn<'a>(
&'a self,
ctx: &'a Context,
) -> Pin<Box<dyn Future<Output = Result<Option<<T as ProvideCredentialDyn>::Credential>, Error>> + Send + 'a>>
fn provide_credential_dyn<'a>( &'a self, ctx: &'a Context, ) -> Pin<Box<dyn Future<Output = Result<Option<<T as ProvideCredentialDyn>::Credential>, Error>> + Send + 'a>>
ProvideCredential::provide_credential.