AWS AmazonCloudWatch documentation change
Summary
Removed the 'Get started' section and code examples for .NET, Java, and Kotlin demonstrating CloudWatch ListMetrics API usage
Security assessment
The change removes introductory code samples without any security context. There's no evidence of vulnerability fixes, security weaknesses, or incident response. The examples demonstrated basic metric listing functionality without security implications.
Diff
diff --git a/AmazonCloudWatch/latest/monitoring/service_code_examples.md b/AmazonCloudWatch/latest/monitoring/service_code_examples.md index 1763d57a4..d4be1397d 100644 --- a//AmazonCloudWatch/latest/monitoring/service_code_examples.md +++ b//AmazonCloudWatch/latest/monitoring/service_code_examples.md @@ -17,200 +16,0 @@ For a complete list of AWS SDK developer guides and code examples, see [Using Cl -**Get started** - -The following code examples show how to get started using CloudWatch. - -.NET - - -**SDK for .NET (v4)** - - -###### Note - -There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv4/CloudWatch#code-examples). - - - using Amazon.CloudWatch; - using Amazon.CloudWatch.Model; - using Microsoft.Extensions.DependencyInjection; - using Microsoft.Extensions.Hosting; - - namespace CloudWatchActions; - - public static class HelloCloudWatch - { - static async Task Main(string[] args) - { - // Use the AWS .NET Core Setup package to set up dependency injection for the Amazon CloudWatch service. - // Use your AWS profile name, or leave it blank to use the default profile. - using var host = Host.CreateDefaultBuilder(args) - .ConfigureServices((_, services) => - services.AddAWSService<IAmazonCloudWatch>() - ).Build(); - - // Now the client is available for injection. - var cloudWatchClient = host.Services.GetRequiredService<IAmazonCloudWatch>(); - - // You can use await and any of the async methods to get a response. - var metricNamespace = "AWS/Billing"; - var response = await cloudWatchClient.ListMetricsAsync(new ListMetricsRequest - { - Namespace = metricNamespace - }); - Console.WriteLine($"Hello Amazon CloudWatch! Following are some metrics available in the {metricNamespace} namespace:"); - Console.WriteLine(); - if (response.Metrics != null) - { - foreach (var metric in response.Metrics.Take(5)) - { - Console.WriteLine($"\tMetric: {metric.MetricName}"); - Console.WriteLine($"\tNamespace: {metric.Namespace}"); - Console.WriteLine( - $"\tDimensions: {string.Join(", ", metric.Dimensions.Select(m => $"{m.Name}:{m.Value}"))}"); - Console.WriteLine(); - } - } - } - } - - - - * For API details, see [ListMetrics](https://docs.aws.amazon.com/goto/DotNetSDKV4/monitoring-2010-08-01/ListMetrics) in _AWS SDK for .NET API Reference_. - - - - -Java - - -**SDK for Java 2.x** - - -###### Note - -There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javav2/example_code/cloudwatch#code-examples). - - - import software.amazon.awssdk.regions.Region; - import software.amazon.awssdk.services.cloudwatch.CloudWatchClient; - import software.amazon.awssdk.services.cloudwatch.model.CloudWatchException; - import software.amazon.awssdk.services.cloudwatch.model.ListMetricsRequest; - import software.amazon.awssdk.services.cloudwatch.paginators.ListMetricsIterable; - - /** - * Before running this Java V2 code example, set up your development - * environment, including your credentials. - * - * For more information, see the following documentation topic: - * - * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html - */ - public class HelloService { - public static void main(String[] args) { - final String usage = """ - - Usage: - <namespace>\s - - Where: - namespace - The namespace to filter against (for example, AWS/EC2).\s - """; - - if (args.length != 1) { - System.out.println(usage); - System.exit(1); - } - - String namespace = args[0]; - Region region = Region.US_EAST_1; - CloudWatchClient cw = CloudWatchClient.builder() - .region(region) - .build(); - - listMets(cw, namespace); - cw.close(); - } - - public static void listMets(CloudWatchClient cw, String namespace) { - try { - ListMetricsRequest request = ListMetricsRequest.builder() - .namespace(namespace) - .build(); - - ListMetricsIterable listRes = cw.listMetricsPaginator(request); - listRes.stream() - .flatMap(r -> r.metrics().stream()) - .forEach(metrics -> System.out.println(" Retrieved metric is: " + metrics.metricName())); - - } catch (CloudWatchException e) { - System.err.println(e.awsErrorDetails().errorMessage()); - System.exit(1); - } - } - } - - - - * For API details, see [ListMetrics](https://docs.aws.amazon.com/goto/SdkForJavaV2/monitoring-2010-08-01/ListMetrics) in _AWS SDK for Java 2.x API Reference_. - - - - -Kotlin - - -**SDK for Kotlin** - - -###### Note - -There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/kotlin/services/cloudwatch#code-examples). - - - /** - Before running this Kotlin code example, set up your development environment, - including your credentials. - - For more information, see the following documentation topic: - https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html - */ - suspend fun main(args: Array<String>) { - val usage = """ - Usage: - <namespace> - Where: - namespace - The namespace to filter against (for example, AWS/EC2). - """ - - if (args.size != 1) { - println(usage) - exitProcess(0) - } - - val namespace = args[0] - listAllMets(namespace) - } - - suspend fun listAllMets(namespaceVal: String?) { - val request = - ListMetricsRequest { - namespace = namespaceVal - } - - CloudWatchClient.fromEnvironment { region = "us-east-1" }.use { cwClient -> - cwClient - .listMetricsPaginated(request) - .transform { it.metrics?.forEach { obj -> emit(obj) } } - .collect { obj -> - println("Name is ${obj.metricName}") - println("Namespace is ${obj.namespace}") - } - } - } - - -