Skip to content

Commit

Permalink
handle credentials better
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Kordish committed Aug 17, 2018
1 parent 058a777 commit 5c891c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ rusoto_sts = "*"
rusoto_credential = "*"
cadence = "*"
elapsed = "*"
futures = "*"

[profile.release]
opt-level = 3
Expand Down
19 changes: 7 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// Opt in to unstable features expected for Rust 2018
#![feature(rust_2018_preview)]
// Opt in to warnings about new 2018 idioms
#![feature(rust_2018_idioms)]
// #![feature(rust_2018_idioms)]
#![cfg_attr(feature = "cargo-clippy", allow(clippy_pedantic))]

use cadence::{prelude::*, BufferedUdpMetricSink, QueuingMetricSink, StatsdClient, DEFAULT_PORT};
use chrono::{prelude::Local, Datelike, Duration, Timelike};
use crossbeam::scope;
use elapsed::measure_time;
use flate2::{write::GzEncoder, Compression};
use futures::future::Future;
use rusoto_core::Region;
use rusoto_credential::AutoRefreshingProvider;
use rusoto_credential::{AutoRefreshingProvider, ProvideAwsCredentials};
use rusoto_s3::{PutObjectRequest, S3Client, StreamingBody, S3};
use rusoto_sts::{StsAssumeRoleSessionCredentialsProvider, StsClient};
use serde_derive::{Deserialize, Serialize};
Expand Down Expand Up @@ -295,16 +296,10 @@ fn write_s3(
None
);

// allow our STS to auto-refresh
let _auto_sts_provider = match AutoRefreshingProvider::new(sts_provider) {
Ok(auto_sts_provider) => auto_sts_provider,
Err(_) => {
logging(&config.clone(), "crit", "Unable to obtain STS token").is_ok();
exit(1)
}
};

// auto_sts_provider.credentials().wait();
#[allow(unused_variables)]
let credentials = AutoRefreshingProvider::new(sts_provider)?
.credentials()
.wait()?;

// create our s3 client initialization
let s3 = S3Client::new(Region::from_str(&config.region)?);
Expand Down

0 comments on commit 5c891c3

Please sign in to comment.