[−][src]Struct rusoto_credential::EnvironmentProvider
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; 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().wait().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().wait().unwrap(); assert_eq!(creds.expires_at().unwrap().to_rfc3339(), "2018-04-21T01:13:02+00:00");
Methods
impl EnvironmentProvider
[src]
pub fn with_prefix(prefix: &str) -> Self
[src]
Create an EnvironmentProvider with a non-standard variable prefix.
use futures::future::Future; use rusoto_credential::{EnvironmentProvider, ProvideAwsCredentials}; use std::env; 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().wait().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().wait().unwrap(); assert_eq!(creds.expires_at().unwrap().to_rfc3339(), "2018-04-21T01:13:02+00:00");
Trait Implementations
impl ProvideAwsCredentials for EnvironmentProvider
[src]
type Future = EnvironmentProviderFuture
The future response value.
fn credentials(&self) -> Self::Future
[src]
impl Default for EnvironmentProvider
[src]
impl Clone for EnvironmentProvider
[src]
fn clone(&self) -> EnvironmentProvider
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for EnvironmentProvider
[src]
Auto Trait Implementations
impl Send for EnvironmentProvider
impl Sync for EnvironmentProvider
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
T: From<U>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,