Skip to content

Conversation

@scmacdon
Copy link
Contributor

@scmacdon scmacdon commented Dec 4, 2025

This pull request adds Java V2 examples for Control Tower.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@scmacdon scmacdon self-assigned this Dec 4, 2025
@scmacdon scmacdon added Java-v2 This issue relates to the AWS SDK for Java V2 Basics A basic code example showing the core actions for a particular service. labels Dec 4, 2025
@scmacdon scmacdon changed the title Java V2 Add Java V2 examples for Control Tower Java V2 Add examples for Control Tower Dec 4, 2025
@brmur brmur requested a review from rlhagerm December 8, 2025 15:34
excerpts:
- description:
snippet_tags:
- controltower.java2.list_landing_zones.main
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect snippet name.

do {
ListLandingZonesRequest.Builder requestBuilder = ListLandingZonesRequest.builder();
if (nextToken != null) {
requestBuilder.nextToken(nextToken);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should use the paginator.

return baselines;

} catch (ControlTowerException e) {
String errorCode = e.awsErrorDetails().errorCode();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exception code looks different from the established patterns in the rest of the Java examples. It looks too similar to the .NET code, are you sure it is correct? Same question for all of the exception handlers.

String nextToken = null;

do {
ListEnabledBaselinesRequest.Builder requestBuilder = ListEnabledBaselinesRequest.builder();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code should use the paginator.


try {

ControlTowerClient controlTowerClient = ControlTowerClient.builder()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the Java code not using async operations any more?

waitForInputToContinue(scanner);
/*
logger.info(DASHES);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented out code.

*/
} catch (ControlTowerException e) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the rest of the scenario? The specification includes a lot more than just listing enabled baselines. See the sections on Baselines and the sections on Controls in the specification here: https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/scenarios/basics/controltower/SPECIFICATION.md

public static void main(String[] args) {
try {
ControlTowerClient controlTowerClient = ControlTowerClient.builder()
.region(Region.US_EAST_1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard coded region.

@@ -0,0 +1,3 @@
dataAccessRoleArn = <enter data access role ARN>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this file have to do with the scenario? DocumentClassifier?

* @throws ControlTowerException if a service-specific error occurs
* @throws SdkException if an SDK error occurs
*/
public static BaselineOperationStatus getBaselineOperation(ControlTowerClient controlTowerClient,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods are never called by the scenario?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Basics A basic code example showing the core actions for a particular service. Java-v2 This issue relates to the AWS SDK for Java V2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants