-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rust: Add proper hello-world for Aurora (#5605)
* Rust: Add proper hello-world for Aurora
- Loading branch information
1 parent
a29f4e9
commit e68209e
Showing
2 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use aws_sdk_rds::Client; | ||
|
||
#[derive(Debug)] | ||
struct Error(String); | ||
impl std::fmt::Display for Error { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "{}", self.0) | ||
} | ||
} | ||
impl std::error::Error for Error {} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Error> { | ||
tracing_subscriber::fmt::init(); | ||
let sdk_config = aws_config::from_env().load().await; | ||
let client = Client::new(&sdk_config); | ||
|
||
let describe_db_clusters_output = client | ||
.describe_db_clusters() | ||
.send() | ||
.await | ||
.map_err(|e| Error(e.to_string()))?; | ||
println!( | ||
"Found {} clusters:", | ||
describe_db_clusters_output.db_clusters().len() | ||
); | ||
for cluster in describe_db_clusters_output.db_clusters() { | ||
let name = cluster.database_name().unwrap_or("Unknown"); | ||
let engine = cluster.engine().unwrap_or("Unknown"); | ||
let id = cluster.db_cluster_identifier().unwrap_or("Unknown"); | ||
let class = cluster.db_cluster_instance_class().unwrap_or("Unknown"); | ||
println!("\tDatabase: {name}",); | ||
println!("\t Engine: {engine}",); | ||
println!("\t ID: {id}",); | ||
println!("\tInstance: {class}",); | ||
} | ||
|
||
Ok(()) | ||
} |