Struct rusoto_credential::EnvironmentProvider [−][src]
Provides AWS credentials from environment variables.
Available Environment Variables
-
AWS_ACCESS_KEY_ID
: -
AWS_SECRET_ACCESS_KEY
: -
AWS_SESSION_TOKEN
: -
AWS_CREDENTIAL_EXPIRATION
:Expiration time in RFC 3339 format (e.g.
1996-12-19T16:39:57-08:00
). If unset, credentials won’t expire.
Example
use futures::future::Future; use rusoto_credential::{EnvironmentProvider, ProvideAwsCredentials}; use std::env; #[tokio::main] async fn main() { env::set_var("AWS_ACCESS_KEY_ID", "ANTN35UAENTS5UIAEATD"); env::set_var("AWS_SECRET_ACCESS_KEY", "TtnuieannGt2rGuie2t8Tt7urarg5nauedRndrur"); env::set_var("AWS_SESSION_TOKEN", "DfnGs8Td4rT8r4srxAg6Td4rT8r4srxAg6GtkTir"); let creds = EnvironmentProvider::default().credentials().await.unwrap(); assert_eq!(creds.aws_access_key_id(), "ANTN35UAENTS5UIAEATD"); assert_eq!(creds.aws_secret_access_key(), "TtnuieannGt2rGuie2t8Tt7urarg5nauedRndrur"); assert_eq!(creds.token(), &Some("DfnGs8Td4rT8r4srxAg6Td4rT8r4srxAg6GtkTir".to_string())); assert!(creds.expires_at().is_none()); // doesn't expire env::set_var("AWS_CREDENTIAL_EXPIRATION", "2018-04-21T01:13:02Z"); let creds = EnvironmentProvider::default().credentials().await.unwrap(); assert_eq!(creds.expires_at().unwrap().to_rfc3339(), "2018-04-21T01:13:02+00:00"); }
Implementations
impl EnvironmentProvider
[src]
pub fn with_prefix(prefix: &str) -> Self
[src]
Create an EnvironmentProvider with a non-standard variable prefix.
use std::future::Future; use rusoto_credential::{EnvironmentProvider, ProvideAwsCredentials}; use std::env; #[tokio::main] async fn main() -> () { env::set_var("MYAPP_ACCESS_KEY_ID", "ANTN35UAENTS5UIAEATD"); env::set_var("MYAPP_SECRET_ACCESS_KEY", "TtnuieannGt2rGuie2t8Tt7urarg5nauedRndrur"); env::set_var("MYAPP_SESSION_TOKEN", "DfnGs8Td4rT8r4srxAg6Td4rT8r4srxAg6GtkTir"); let creds = EnvironmentProvider::with_prefix("MYAPP").credentials().await.unwrap(); assert_eq!(creds.aws_access_key_id(), "ANTN35UAENTS5UIAEATD"); assert_eq!(creds.aws_secret_access_key(), "TtnuieannGt2rGuie2t8Tt7urarg5nauedRndrur"); assert_eq!(creds.token(), &Some("DfnGs8Td4rT8r4srxAg6Td4rT8r4srxAg6GtkTir".to_string())); assert!(creds.expires_at().is_none()); // doesn't expire env::set_var("MYAPP_CREDENTIAL_EXPIRATION", "2018-04-21T01:13:02Z"); let creds = EnvironmentProvider::with_prefix("MYAPP").credentials().await.unwrap(); assert_eq!(creds.expires_at().unwrap().to_rfc3339(), "2018-04-21T01:13:02+00:00"); }
Trait Implementations
impl Clone for EnvironmentProvider
[src]
fn clone(&self) -> EnvironmentProvider
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for EnvironmentProvider
[src]
impl Default for EnvironmentProvider
[src]
impl ProvideAwsCredentials for EnvironmentProvider
[src]
fn credentials<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<AwsCredentials, CredentialsError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
[src]
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<AwsCredentials, CredentialsError>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Auto Trait Implementations
impl RefUnwindSafe for EnvironmentProvider
impl Send for EnvironmentProvider
impl Sync for EnvironmentProvider
impl Unpin for EnvironmentProvider
impl UnwindSafe for EnvironmentProvider
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,