diff --git a/aws/sdk/build.gradle.kts b/aws/sdk/build.gradle.kts index bc793166ab..1b0724ec86 100644 --- a/aws/sdk/build.gradle.kts +++ b/aws/sdk/build.gradle.kts @@ -80,6 +80,7 @@ val tier1Services = setOf( "sqs", "ssm", "sts", + "cloudwatch", "ecr", "eks" ) diff --git a/aws/sdk/examples/cloudwatch/Cargo.toml b/aws/sdk/examples/cloudwatch/Cargo.toml new file mode 100644 index 0000000000..a006b429e6 --- /dev/null +++ b/aws/sdk/examples/cloudwatch/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "cloudwatch-code-examples" +version = "0.1.0" +authors = ["AWS Rust SDK Team ", "Russell Cohen "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +cloudwatch = { package = "aws-sdk-cloudwatch", path = "../../build/aws-sdk/cloudwatch" } +tokio = { version = "1", features = ["full"] } +tracing-subscriber = { version = "0.2", features = ["fmt"] } diff --git a/aws/sdk/examples/cloudwatch/src/bin/list-metrics.rs b/aws/sdk/examples/cloudwatch/src/bin/list-metrics.rs new file mode 100644 index 0000000000..4a4d941624 --- /dev/null +++ b/aws/sdk/examples/cloudwatch/src/bin/list-metrics.rs @@ -0,0 +1,20 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +use cloudwatch::Client; + +#[tokio::main] +async fn main() -> Result<(), cloudwatch::Error> { + tracing_subscriber::fmt::init(); + + let client = Client::from_env(); + let rsp = client.list_metrics().send().await?; + let metrics = rsp.metrics.unwrap_or_default(); + println!("found {} metric(s)", metrics.len()); + for metric in metrics { + println!("metric: {:?}", metric); + } + Ok(()) +}