Created
January 6, 2018 20:13
-
-
Save btbytes/1f62988ab1454b57d947dd89fcb925b5 to your computer and use it in GitHub Desktop.
List of S3 buckets using Rust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "my-s3-buckets" | |
version = "0.1.0" | |
authors = ["Me Me <me@myemailprovider.com>"] | |
[dependencies] | |
rusoto_core = "0.30.0" | |
rusoto_s3 = "0.30.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate rusoto_core; | |
extern crate rusoto_s3; | |
use rusoto_core::{DefaultCredentialsProvider, Region}; | |
use rusoto_core::default_tls_client; | |
use rusoto_s3::{S3, S3Client}; | |
fn main() { | |
let provider = DefaultCredentialsProvider::new().unwrap(); | |
let client = S3Client::new(default_tls_client().unwrap(), provider, Region::UsEast1); | |
match client.list_buckets() { | |
Ok(output) => { | |
match output.buckets { | |
Some(bucket_list) => { | |
println!("Bucket list: "); | |
for bucket in bucket_list { | |
println!("{:?}", bucket.name.unwrap()); | |
} | |
} | |
None => println!("No buckets were found.") | |
} | |
} | |
Err(error) => { | |
println!("Error: {:?}", error); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment