AWS code-library documentation change
Summary
Updated AWS Control Tower code examples across multiple languages (C#, Java, Python) with version bump from 4.0 to 5.0, added comprehensive Java implementation, improved error handling, and enhanced parameter handling logic.
Security assessment
The changes primarily update baseline versions and add new language examples without addressing security vulnerabilities. No security patches, vulnerability disclosures, or security-specific documentation were introduced. The version update appears routine, and the Java addition expands language support without security implications.
Diff
diff --git a/code-library/latest/ug/controltower_example_controltower_Scenario_section.md b/code-library/latest/ug/controltower_example_controltower_Scenario_section.md index a7a1b93ce..1ed6aca8e 100644 --- a//code-library/latest/ug/controltower_example_controltower_Scenario_section.md +++ b//code-library/latest/ug/controltower_example_controltower_Scenario_section.md @@ -160 +160 @@ Run an interactive scenario demonstrating AWS Control Tower features. - controlTowerBaseline.Arn, "4.0", icBaselineArn ?? ""); + controlTowerBaseline.Arn, "5.0", icBaselineArn ?? ""); @@ -173,0 +174,2 @@ Run an interactive scenario demonstrating AWS Control Tower features. + alreadyEnabled = true; + Console.WriteLine("No change, the selected baseline was already enabled."); @@ -177,3 +178,0 @@ Run an interactive scenario demonstrating AWS Control Tower features. - - alreadyEnabled = true; - Console.WriteLine("No change, the selected baseline was already enabled."); @@ -203 +202 @@ Run an interactive scenario demonstrating AWS Control Tower features. - controlTowerBaseline.Arn, "4.0", icBaselineArn ?? ""); + controlTowerBaseline.Arn, "5.0", icBaselineArn ?? ""); @@ -443 +442 @@ Wrapper methods that are called by the scenario to manage Aurora actions. - /// <returns>The enabled baseline ARN or null if already enabled.</returns> + /// <returns>The enabled baseline ARN or null.</returns> @@ -448 +447,2 @@ Wrapper methods that are called by the scenario to manage Aurora actions. - var parameters = new List<EnabledBaselineParameter> + var parameters = new List<EnabledBaselineParameter>(); + if (!string.IsNullOrEmpty(identityCenterBaseline)) @@ -449,0 +450 @@ Wrapper methods that are called by the scenario to manage Aurora actions. + parameters.Add( @@ -453,0 +455 @@ Wrapper methods that are called by the scenario to manage Aurora actions. + }); @@ -455,2 +456,0 @@ Wrapper methods that are called by the scenario to manage Aurora actions. - }; - @@ -482 +482 @@ Wrapper methods that are called by the scenario to manage Aurora actions. - catch (ValidationException ex) when (ex.Message.Contains("already enabled")) + catch (ValidationException ex) @@ -483,0 +484 @@ Wrapper methods that are called by the scenario to manage Aurora actions. + if (ex.Message.Contains("already enabled")) @@ -484,0 +486,2 @@ Wrapper methods that are called by the scenario to manage Aurora actions. + else { Console.WriteLine(ex.Message); } + // Write the message and return null if baseline cannot be enabled. @@ -842,0 +846,1329 @@ Wrapper methods that are called by the scenario to manage Aurora actions. +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/controltower#code-examples). + +Run an interactive scenario demonstrating AWS Control Tower features. + + + public class ControlTowerScenario { + public static final String DASHES = new String(new char[80]).replace("\0", "-"); + private static final Scanner scanner = new Scanner(in); + + private static OrganizationsClient orgClient; + private static ControlCatalogClient catClient; + + private static String ouId = null; + private static String ouArn = null; + private static String landingZoneArn = null; + private static boolean useLandingZone = false; + + private String stack = null; + private String accountId = null; + + public static void main(String[] args) { + + System.out.println(DASHES); + System.out.println("Welcome to the AWS Control Tower basics scenario!"); + System.out.println(DASHES); + + try { + runScenarioAsync(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + // ----------------------------- + // Utilities + // ----------------------------- + private static boolean askYesNo(String msg) { + System.out.println(msg); + return scanner.nextLine().trim().toLowerCase().startsWith("y"); + } + + private static void runScenarioAsync() { + try { + ControlTowerActions actions = new ControlTowerActions(); + + // ----------------------------- + // Step 1: Landing Zones + // ----------------------------- + System.out.println(DASHES); + System.out.println(""" + Some demo operations require the use of a landing zone. + You can use an existing landing zone or opt out of these operations in the demo. + For instructions on how to set up a landing zone, + see https://docs.aws.amazon.com/controltower/latest/userguide/getting-started-from-console.html + """); + + System.out.println("Step 1: Listing landing zones..."); + waitForInputToContinue(scanner); + + List<LandingZoneSummary> landingZones = + actions.listLandingZonesAsync().join(); + + if (landingZones.isEmpty()) { + System.out.println("No landing zones found. Landing-zone-dependent steps will be skipped."); + useLandingZone = false; + waitForInputToContinue(scanner); + } else { + System.out.println("\nAvailable Landing Zones:"); + for (int i = 0; i < landingZones.size(); i++) { + System.out.printf("%d) %s%n", i + 1, landingZones.get(i).arn()); + } + + if (askYesNo("Do you want to use the first landing zone in the list (" + + landingZones.get(0).arn() + ")? (y/n): ")) { + useLandingZone = true; + landingZoneArn = landingZones.get(0).arn(); + } else if (askYesNo("Do you want to use a different existing Landing Zone for this demo? (y/n): ")) { + useLandingZone = true; + System.out.println("Enter landing zone ARN: "); + landingZoneArn = scanner.nextLine().trim(); + } else { + System.out.println("Proceeding without a landing zone."); + useLandingZone = false; + waitForInputToContinue(scanner); + } + } + + // ----------------------------- + // Setup Organization + Sandbox OU + // ----------------------------- + if (useLandingZone) { + System.out.println("Using landing zone ARN: " + landingZoneArn); + + ControlTowerActions.OrgSetupResult result = + actions.setupOrganizationAsync().join(); + + ouArn = result.sandboxOuArn(); + ouId = result.sandboxOuArn(); + + System.out.println("Organization ID: " + result.orgId()); + System.out.println("Using Sandbox OU ARN: " + ouArn); + } + + // ----------------------------- + // Step 2: Baselines + // ----------------------------- + System.out.println(DASHES); + System.out.println("Step 2: Listing available baselines..."); + System.out.println(""" + In this step, the program lists available AWS Control Tower baselines and may perform + baseline-related operations (enable, disable, reset) if requested. + + NOTE: + AWS Control Tower enforces governance through baselines and mandatory controls + (guardrails). Mandatory controls are required for landing zone governance and may + restrict certain operations depending on the account, region, or organizational policy. + + For more information, see: + - Types of baselines in AWS Control Tower: + https://docs.aws.amazon.com/controltower/latest/userguide/types-of-baselines.html + - Mandatory controls (guardrails) in AWS Control Tower: + https://docs.aws.amazon.com/controltower/latest/controlreference/mandatory-controls.html + - Baseline API examples: + https://docs.aws.amazon.com/controltower/latest/userguide/baseline-api-examples.html + """); + + + + waitForInputToContinue(scanner); + List<BaselineSummary> baselines = + actions.listBaselinesAsync().join(); + + BaselineSummary controlTowerBaseline = null; + for (BaselineSummary b : baselines) { + System.out.println("Baseline: " + b.name()); + System.out.println(" ARN: " + b.arn()); + if ("AWSControlTowerBaseline".equals(b.name())) { + controlTowerBaseline = b; + } + } + + waitForInputToContinue(scanner); + + if (useLandingZone && controlTowerBaseline != null) { + + System.out.println("\nListing enabled baselines:"); + List<EnabledBaselineSummary> enabledBaselines = + actions.listEnabledBaselinesAsync().join(); + + String enabledBaselineArn = null; + for (EnabledBaselineSummary eb : enabledBaselines) { + System.out.println("Checking enabled baseline ARN: " + eb.arn());