From e2f8eb98c277d84828a998cc11e06abeafd3c502 Mon Sep 17 00:00:00 2001 From: Roman Valls Guimera Date: Tue, 12 Oct 2021 14:11:30 +1100 Subject: [PATCH] Add default provider chain so that it goes through the creds available on lambda (from ENV): https://github.com/awslabs/aws-sdk-rust/blob/main/sdk/aws-config/src/default_provider.rs#L111 --- Cargo.toml | 2 +- src/main.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c95edc4..156b1cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,8 @@ serde_derive = "^1" serde_json = "^1" lambda_runtime = { version = "0.4.1" } aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.19-alpha" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", tag = "v0.0.19-alpha" } tracing-subscriber = "0.2.25" - tokio = { version = "1.12.0" } noodles = { version = "0.10.1", features = ["bam", "sam"] } diff --git a/src/main.rs b/src/main.rs index 985371a..dee3940 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ use std::io::{Cursor}; use lambda_runtime::{ handler_fn, Context, Error }; use serde_json::{ json, Value }; +use aws_config::default_provider::credentials::DefaultCredentialsChain; use aws_sdk_s3 as s3; use s3::Region; @@ -44,8 +45,13 @@ async fn s3_read_bam_header(_event: Value, _ctx: Context) -> Result Result { + let creds_provider = DefaultCredentialsChain::builder() + .region(Region::new(REGION)) + .build().await; + let conf = s3::Config::builder() .region(Region::new(REGION)) + .credentials_provider(creds_provider) .build(); let client = s3::Client::from_conf(conf);