AWS Security ChangesHomeSearch

AWS AmazonCloudWatch: Refactor CloudWatch DescribeAnomalyDetectors Kotlin example to parameters

Service: AmazonCloudWatch · 2026-09-27 · Documentation low

File: AmazonCloudWatch/latest/monitoring/example_cloudwatch_DescribeAnomalyDetectors_section.md

Summary

The Kotlin example for DescribeAnomalyDetectors was rewritten to accept namespace and metric name as function parameters instead of reading them from a JSON file via Jackson's ObjectMapper/JsonFactory, and variable names were cleaned up (detectorsRequest -> request). Removed the 'Action examples ... in context' pointer list.

Security assessment

Purely a code-sample refactor: local file parsing (JsonFactory/ObjectMapper on a JSON file) was replaced by direct string parameters, and a request variable was renamed. No auth, encryption, IAM, or vulnerability-fix content is present, so there is no concrete security implication.

Evidence

+        namespace = namespaceVal

Diff

diff --git a/AmazonCloudWatch/latest/monitoring/example_cloudwatch_DescribeAnomalyDetectors_section.md b/AmazonCloudWatch/latest/monitoring/example_cloudwatch_DescribeAnomalyDetectors_section.md
index 4ac5468fa..2b5b3b07a 100644
--- a//AmazonCloudWatch/latest/monitoring/example_cloudwatch_DescribeAnomalyDetectors_section.md
+++ b//AmazonCloudWatch/latest/monitoring/example_cloudwatch_DescribeAnomalyDetectors_section.md
@@ -11,7 +10,0 @@ The following code examples show how to use `DescribeAnomalyDetectors`.
-Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example: 
-
-  * [Learn the basics](./example_cloudwatch_GetStartedMetricsDashboardsAlarms_section.html)
-
-
-
-
@@ -209,8 +202,5 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
-    suspend fun describeAnomalyDetectors(fileName: String) {
-        // Read values from the JSON file.
-        val parser = JsonFactory().createParser(File(fileName))
-        val rootNode = ObjectMapper().readTree<JsonNode>(parser)
-        val customMetricNamespace = rootNode.findValue("customMetricNamespace").asText()
-        val customMetricName = rootNode.findValue("customMetricName").asText()
-    
-        val detectorsRequest =
+    suspend fun describeAnomalyDetectors(
+        namespaceVal: String,
+        metricNameVal: String,
+    ) {
+        val request =
@@ -219,2 +209,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
-                metricName = customMetricName
-                namespace = customMetricNamespace
+                namespace = namespaceVal
+                metricName = metricNameVal
@@ -223 +214 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
-            val response = cwClient.describeAnomalyDetectors(detectorsRequest)
+            val response = cwClient.describeAnomalyDetectors(request)