[][src]Struct rusoto_credential::EnvironmentProvider

pub struct EnvironmentProvider { /* fields omitted */ }

Provides AWS credentials from environment variables.

Available Environment Variables

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.

impl Default for EnvironmentProvider[src]

impl Clone for 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]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T