Skip to content

Commit b214fb6

Browse files
authored
Java/Kotlin made some minor modifications to SDK examples (#7228)
1 parent f75c558 commit b214fb6

File tree

9 files changed

+177
-185
lines changed

9 files changed

+177
-185
lines changed

javav2/example_code/forecast/src/test/java/ForecastTest.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,6 @@ public static void setUp() {
4545
predARN = values.getPredARN();
4646
forecastName = values.getForecastName() + randomNum;
4747
dataSet = values.getDataSet() + randomNum;
48-
49-
// Uncomment this code block if you prefer using a config.properties file to
50-
// retrieve AWS values required for these tests.
51-
/*
52-
*
53-
* try (InputStream input =
54-
* ForecastTest.class.getClassLoader().getResourceAsStream("config.properties"))
55-
* {
56-
* Properties prop = new Properties();
57-
* if (input == null) {
58-
* System.out.println("Sorry, unable to find config.properties");
59-
* return;
60-
* }
61-
*
62-
* // Populate the data members required for all tests.
63-
* predARN = "arn:aws:forecast:us-west-2:814548047983:predictor/ScottPredictor";
64-
* forecastName = "forecast"+randomNum;
65-
* dataSet = "dataSet"+randomNum;
66-
*
67-
* } catch (IOException ex) {
68-
* ex.printStackTrace();
69-
* }
70-
*/
7148
}
7249

7350
@Test

javav2/example_code/s3/src/main/java/com/example/s3/PutBucketLogging.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,28 @@ public static void main(String[] args) {
3333
final String usage = """
3434
3535
Usage:
36-
<bucketName> <targetBucket> \s
36+
<bucketName> <targetBucket> <accountId> \s
3737
3838
Where:
3939
bucketName - The Amazon S3 bucket to upload an object into.
40-
targetBucket - The target bucket .
40+
targetBucket - The target bucket.
41+
accountId - The account id.
4142
""";
4243

43-
if (args.length != 2) {
44+
if (args.length != 3) {
4445
System.out.println(usage);
4546
System.exit(1);
4647
}
4748

4849
String bucketName = args[0];
4950
String targetBucket = args[1];
51+
String accountId = args[2];
5052
Region region = Region.US_EAST_1;
5153
S3Client s3 = S3Client.builder()
5254
.region(region)
5355
.build();
5456

55-
setlogRequest(s3, bucketName, targetBucket);
57+
setlogRequest(s3, bucketName, targetBucket, accountId);
5658
s3.close();
5759
}
5860

@@ -62,10 +64,11 @@ public static void main(String[] args) {
6264
* @param s3 an instance of the {@link S3Client} used to interact with the S3 service
6365
* @param bucketName the name of the bucket for which logging needs to be enabled
6466
* @param targetBucket the name of the target bucket where the logs will be stored
67+
* @param accountId the account Id
6568
*
6669
* @throws S3Exception if an error occurs while enabling logging for the bucket
6770
*/
68-
public static void setlogRequest(S3Client s3, String bucketName, String targetBucket) {
71+
public static void setlogRequest(S3Client s3, String bucketName, String targetBucket, String accountId) {
6972
try {
7073
GetBucketAclRequest aclRequest = GetBucketAclRequest.builder()
7174
.bucket(targetBucket)
@@ -96,7 +99,7 @@ public static void setlogRequest(S3Client s3, String bucketName, String targetBu
9699

97100
PutBucketLoggingRequest loggingRequest = PutBucketLoggingRequest.builder()
98101
.bucket(bucketName)
99-
.expectedBucketOwner("814548047983")
102+
.expectedBucketOwner(accountId)
100103
.bucketLoggingStatus(loggingStatus)
101104
.build();
102105

javav2/example_code/sns/src/main/java/com/example/sns/CreateFIFOTopic.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public static void main(String[] args) {
3535
System.exit(1);
3636
}
3737

38-
String fifoTopicName = "PriceUpdatesTopic3.fifo";
39-
String fifoQueueARN = "arn:aws:sqs:us-east-1:814548047983:MyPriceSQS.fifo";
38+
String fifoTopicName = args[0];
39+
String fifoQueueARN = args[1];
4040
SnsClient snsClient = SnsClient.builder()
4141
.region(Region.US_EAST_1)
4242
.build();

javav2/usecases/topics_and_queues/pom.xml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
<artifactId>maven-compiler-plugin</artifactId>
2929
<version>3.1</version>
3030
<configuration>
31-
<source>8</source>
32-
<target>8</target>
31+
<source>15</source>
32+
<target>15</target>
3333
</configuration>
3434
</plugin>
3535
</plugins>
@@ -39,7 +39,7 @@
3939
<dependency>
4040
<groupId>software.amazon.awssdk</groupId>
4141
<artifactId>bom</artifactId>
42-
<version>2.21.20</version>
42+
<version>2.29.45</version>
4343
<type>pom</type>
4444
<scope>import</scope>
4545
</dependency>
@@ -87,5 +87,13 @@
8787
<artifactId>gson</artifactId>
8888
<version>2.10.1</version>
8989
</dependency>
90+
<dependency>
91+
<groupId>software.amazon.awssdk</groupId>
92+
<artifactId>sso</artifactId>
93+
</dependency>
94+
<dependency>
95+
<groupId>software.amazon.awssdk</groupId>
96+
<artifactId>ssooidc</artifactId>
97+
</dependency>
9098
</dependencies>
9199
</project>

0 commit comments

Comments
 (0)