Skip to main content

ECSCredentialProvider

Struct ECSCredentialProvider 

Source
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

§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 request
  • AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE: File containing the authorization token
  • ECS_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

Source

pub fn new() -> Self

Create a new ECS credential provider

Source

pub fn with_endpoint(self, endpoint: impl Into<String>) -> Self

Create with custom endpoint

Source

pub fn with_auth_token(self, token: impl Into<String>) -> Self

Create with custom auth token

Source

pub fn with_auth_token_file(self, file_path: impl Into<String>) -> Self

Create with custom auth token file path

Source

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

Source

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

Source§

fn clone(&self) -> ECSCredentialProvider

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ECSCredentialProvider

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ECSCredentialProvider

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl ProvideCredential for ECSCredentialProvider

Source§

type Credential = Credential

Credential returned by this loader. Read more
Source§

async fn provide_credential( &self, ctx: &Context, ) -> Result<Option<Self::Credential>>

Load signing credential from current env.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> ProvideCredentialDyn for T

Source§

type Credential = <T as ProvideCredential>::Credential

Credential returned by this loader.
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>>

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V