AWS code-library medium security documentation change
Summary
Modified code example to use AWS CloudFormation for EC2 instance creation, removed hardcoded instance ID parameter, updated region from US_EAST_1 to US_WEST_2, and added stack cleanup.
Security assessment
Automating instance provisioning via CloudFormation reduces manual errors and hardcoding risks. Region change may align with compliance requirements. Stack cleanup prevents resource leaks. These changes improve security posture by enforcing infrastructure-as-code practices.
Diff
diff --git a/code-library/latest/ug/ssm_example_ssm_Scenario_section.md b/code-library/latest/ug/ssm_example_ssm_Scenario_section.md index 878a6a808..f837024e7 100644 --- a//code-library/latest/ug/ssm_example_ssm_Scenario_section.md +++ b//code-library/latest/ug/ssm_example_ssm_Scenario_section.md @@ -41,0 +42 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + import java.util.Map; @@ -44,0 +46 @@ 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"; @@ -49 +51 @@ 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> @@ -52 +53,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). @@ -59,5 +59,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); - } - @@ -68 +64,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."); @@ -265 +266 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - + CloudFormationHelper.destroyCloudFormationStack(ROLES_STACK); @@ -315 +316 @@ A wrapper class for Systems Manager SDK methods. - .region(Region.US_EAST_1) + .region(Region.US_WEST_2)