|
| 1 | +# AWS Control Tower code examples for the SDK for Java 2.x |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This is a workspace where you can find the following AWS SDK for Java 2.x AWS Control Tower examples. |
| 6 | + |
| 7 | +## ⚠ Important |
| 8 | + |
| 9 | +* Running this code might result in charges to your AWS account. |
| 10 | +* Running the tests might result in charges to your AWS account. |
| 11 | +* We recommend that you grant your code least privilege. |
| 12 | + |
| 13 | +## Code examples |
| 14 | + |
| 15 | +### Actions |
| 16 | + |
| 17 | +The following examples show you how to perform actions using the AWS SDK for Java 2.x. |
| 18 | + |
| 19 | +* [List landing zones](src/main/java/com/example/controltower/ControlTowerActions.java) (`ListLandingZones`) |
| 20 | +* [List baselines](src/main/java/com/example/controltower/ControlTowerActions.java) (`ListBaselines`) |
| 21 | +* [List enabled baselines](src/main/java/com/example/controltower/ControlTowerActions.java) (`ListEnabledBaselines`) |
| 22 | +* [Enable baseline](src/main/java/com/example/controltower/ControlTowerActions.java) (`EnableBaseline`) |
| 23 | +* [Disable baseline](src/main/java/com/example/controltower/ControlTowerActions.java) (`DisableBaseline`) |
| 24 | +* [Get baseline operation](src/main/java/com/example/controltower/ControlTowerActions.java) (`GetBaselineOperation`) |
| 25 | +* [List enabled controls](src/main/java/com/example/controltower/ControlTowerActions.java) (`ListEnabledControls`) |
| 26 | +* [Enable control](src/main/java/com/example/controltower/ControlTowerActions.java) (`EnableControl`) |
| 27 | +* [Disable control](src/main/java/com/example/controltower/ControlTowerActions.java) (`DisableControl`) |
| 28 | +* [Get control operation](src/main/java/com/example/controltower/ControlTowerActions.java) (`GetControlOperation`) |
| 29 | + |
| 30 | +### Scenarios |
| 31 | + |
| 32 | +The following examples show you how to implement common scenarios. |
| 33 | + |
| 34 | +* [Learn the basics](src/main/java/com/example/controltower/ControlTowerScenario.java) - Learn the basics by checking setup, managing baselines and controls. |
| 35 | + |
| 36 | +### Hello |
| 37 | + |
| 38 | +* [Hello Control Tower](src/main/java/com/example/controltower/HelloControlTower.java) - Get started with AWS Control Tower. |
| 39 | + |
| 40 | +## Prerequisites |
| 41 | + |
| 42 | +- You must have an AWS account, and have your default credentials and AWS Region configured. |
| 43 | +- Java 17 or later |
| 44 | +- Maven 3.6 or later |
| 45 | +- AWS Control Tower must be set up in your account |
| 46 | + |
| 47 | +## Install |
| 48 | + |
| 49 | +To build and run the examples, navigate to the directory that contains a `pom.xml` file and run the following command: |
| 50 | + |
| 51 | +``` |
| 52 | +mvn compile |
| 53 | +``` |
| 54 | + |
| 55 | +## Run the examples |
| 56 | + |
| 57 | +### Instructions |
| 58 | + |
| 59 | +All examples can be run individually. For example: |
| 60 | + |
| 61 | +``` |
| 62 | +mvn exec:java -Dexec.mainClass="com.example.controltower.HelloControlTower" -Dexec.args="us-east-1" |
| 63 | +``` |
| 64 | + |
| 65 | +### Hello Control Tower |
| 66 | + |
| 67 | +This example shows you how to get started using AWS Control Tower. |
| 68 | + |
| 69 | +``` |
| 70 | +mvn exec:java -Dexec.mainClass="com.example.controltower.HelloControlTower" -Dexec.args="us-east-1" |
| 71 | +``` |
| 72 | + |
| 73 | +### Learn the basics |
| 74 | + |
| 75 | +This interactive scenario runs at a command prompt and shows you how to use AWS Control Tower to do the following: |
| 76 | + |
| 77 | +1. Check Control Tower setup and list landing zones |
| 78 | +2. List available baselines for governance |
| 79 | +3. List currently enabled baselines |
| 80 | +4. Enable baselines for organizational units |
| 81 | +5. List and enable controls for compliance |
| 82 | +6. Monitor operation status |
| 83 | +7. Clean up resources |
| 84 | + |
| 85 | +``` |
| 86 | +mvn exec:java -Dexec.mainClass="com.example.controltower.ControlTowerScenario" -Dexec.args="us-east-1" |
| 87 | +``` |
| 88 | + |
| 89 | +## Run the tests |
| 90 | + |
| 91 | +Unit tests in this module use JUnit 5. To run all of the tests, |
| 92 | +run the following in your [GitHub root]/javav2/example_code/controltower folder. |
| 93 | + |
| 94 | +``` |
| 95 | +mvn test |
| 96 | +``` |
| 97 | + |
| 98 | +## Additional resources |
| 99 | + |
| 100 | +- [AWS Control Tower User Guide](https://docs.aws.amazon.com/controltower/latest/userguide/) |
| 101 | +- [AWS Control Tower API Reference](https://docs.aws.amazon.com/controltower/latest/APIReference/) |
| 102 | +- [AWS SDK for Java 2.x (AWS Control Tower)](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/controltower/package-summary.html) |
0 commit comments