[][src]Struct awscreds::Credentials

pub struct Credentials {
    pub access_key: Option<String>,
    pub secret_key: Option<String>,
    pub security_token: Option<String>,
    pub session_token: Option<String>,
}

AWS access credentials: access key, secret key, and optional token.

Example

Loads from the standard AWS credentials file with the given profile name, defaults to "default".

use awscreds::Credentials;

// Load credentials from `[default]` profile
let credentials = Credentials::default();

// Also loads credentials from `[default]` profile
let credentials = Credentials::new(None, None, None, None, None);

// Load credentials from `[my-profile]` profile
let credentials = Credentials::new(None, None, None, None, Some("my-profile".into()));

// Use anonymous credentials for public objects let credentials = Credentials::anonymous();

Credentials may also be initialized directly or by the following environment variables:

  • AWS_ACCESS_KEY_ID,
  • AWS_SECRET_ACCESS_KEY
  • AWS_SESSION_TOKEN

The order of preference is arguments, then environment, and finally AWS credentials file.

use awscreds::Credentials;

// Load credentials directly
let access_key = "AKIAIOSFODNN7EXAMPLE";
let secret_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY";
let credentials = Credentials::new(Some(access_key), Some(secret_key), None, None, None);

// Load credentials from the environment
use std::env;
env::set_var("AWS_ACCESS_KEY_ID", "AKIAIOSFODNN7EXAMPLE");
env::set_var("AWS_SECRET_ACCESS_KEY", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY");
let credentials = Credentials::new(None, None, None, None, None);

Fields

access_key: Option<String>

AWS public access key.

secret_key: Option<String>

AWS secret key.

security_token: Option<String>

Temporary token issued by AWS service.

session_token: Option<String>

Implementations

impl Credentials[src]

pub fn new_blocking(
    access_key: Option<&str>,
    secret_key: Option<&str>,
    security_token: Option<&str>,
    session_token: Option<&str>,
    profile: Option<&str>
) -> Result<Credentials>
[src]

pub async fn default() -> Result<Credentials>[src]

pub fn default_blocking() -> Result<Credentials>[src]

pub fn anonymous() -> Result<Credentials>[src]

pub async fn new<'_, '_, '_, '_, '_>(
    access_key: Option<&'_ str>,
    secret_key: Option<&'_ str>,
    security_token: Option<&'_ str>,
    session_token: Option<&'_ str>,
    profile: Option<&'_ str>
) -> Result<Credentials>
[src]

Initialize Credentials directly with key ID, secret key, and optional token.

pub fn from_env_specific(
    access_key_var: Option<&str>,
    secret_key_var: Option<&str>,
    security_token_var: Option<&str>,
    session_token_var: Option<&str>
) -> Result<Credentials>
[src]

pub fn from_env() -> Result<Credentials>[src]

pub fn from_profile(section: Option<&str>) -> Result<Credentials>[src]

Trait Implementations

impl Clone for Credentials[src]

impl Debug for Credentials[src]

impl Eq for Credentials[src]

impl PartialEq<Credentials> for Credentials[src]

impl StructuralEq for Credentials[src]

impl StructuralPartialEq for Credentials[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

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

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

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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