AWS Security ChangesHomeSearch

AWS code-library documentation change

Service: code-library · 2025-10-19 · Documentation low

File: code-library/latest/ug/java_2_ssm_code_examples.md

Summary

Modified SSM code example to use CloudFormation for EC2 instance creation, removed manual instanceId input, and updated region settings.

Security assessment

The changes improve code reliability by automating resource creation but do not address security vulnerabilities or document security features. The region change (US_EAST_1 to US_WEST_2) has no direct security implications.

Diff

diff --git a/code-library/latest/ug/java_2_ssm_code_examples.md b/code-library/latest/ug/java_2_ssm_code_examples.md
index 427cf64af..7b28d1b33 100644
--- a//code-library/latest/ug/java_2_ssm_code_examples.md
+++ b//code-library/latest/ug/java_2_ssm_code_examples.md
@@ -138,0 +139 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
+    import java.util.Map;
@@ -141,0 +143 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
+        private static final String ROLES_STACK = "SsmStack3`1";
@@ -146 +148 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
-                  <instanceId> <title> <source> <category> <severity>
+                  <title> <source> <category> <severity>
@@ -149 +150,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
-                    instanceId - The Amazon EC2 Linux/UNIX instance Id that AWS Systems Manager uses (ie, i-0149338494ed95f06). 
@@ -156,5 +156,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
-            if (args.length != 1) {
-                System.out.println(usage);
-                System.exit(1);
-            }
-    
@@ -165 +161,6 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
-            String instanceId = args[0];
+    
+            System.out.println("Use AWS CloudFormation to create the EC2 instance that is required for this scenario.");
+            CloudFormationHelper.deployCloudFormationStack(ROLES_STACK);
+            Map<String, String> stackOutputs = CloudFormationHelper.getStackOutputsAsync(ROLES_STACK).join();
+            String instanceId = stackOutputs.get("InstanceId");
+            System.out.println("The Instance ID: " + instanceId +" was created.");
@@ -362 +363 @@ There's more on GitHub. Find the complete example and learn how to set up and ru
-    
+            CloudFormationHelper.destroyCloudFormationStack(ROLES_STACK);
@@ -412 +413 @@ A wrapper class for Systems Manager SDK methods.
-                        .region(Region.US_EAST_1)
+                        .region(Region.US_WEST_2)