Skip to content

Commit 6dffbf9

Browse files
add util code for creating SSM clients (#23)
1 parent ae4053a commit 6dffbf9

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@
145145
<artifactId>sqs</artifactId>
146146
<version>${aws.sdkv2.version}</version>
147147
<scope>provided</scope>
148+
</dependency>
149+
<dependency>
150+
<groupId>software.amazon.awssdk</groupId>
151+
<artifactId>ssm</artifactId>
152+
<version>${aws.sdkv2.version}</version>
153+
<scope>provided</scope>
148154
</dependency>
149155
<dependency>
150156
<groupId>software.amazon.awssdk</groupId>

src/main/java/cloud/localstack/awssdkv2/TestUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import software.amazon.awssdk.services.sns.*;
88
import software.amazon.awssdk.services.sqs.*;
99
import software.amazon.awssdk.services.s3.*;
10+
import software.amazon.awssdk.services.ssm.*;
1011
import software.amazon.awssdk.auth.credentials.*;
1112
import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient;
1213
import software.amazon.awssdk.core.client.builder.SdkAsyncClientBuilder;
@@ -34,6 +35,10 @@ public static SnsAsyncClient getClientSNSAsyncV2() {
3435
return wrapApiClientV2(SnsAsyncClient.builder(), Localstack.INSTANCE.getEndpointSNS()).build();
3536
}
3637

38+
public static SsmAsyncClient getClientSSMAsyncV2() {
39+
return wrapApiClientV2(SsmAsyncClient.builder(), Localstack.INSTANCE.getEndpointSSM()).build();
40+
}
41+
3742
public static S3AsyncClient getClientS3AsyncV2() {
3843
return wrapApiClientV2(S3AsyncClient.builder(), Localstack.INSTANCE.getEndpointS3()).build();
3944
}

src/test/java/cloud/localstack/awssdkv2/BasicFeaturesSDKV2Test.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import software.amazon.awssdk.services.sns.model.*;
1414
import software.amazon.awssdk.services.sqs.*;
1515
import software.amazon.awssdk.services.sqs.model.*;
16+
import software.amazon.awssdk.services.ssm.*;
17+
import software.amazon.awssdk.services.ssm.model.*;
1618
import software.amazon.awssdk.auth.credentials.*;
1719
import software.amazon.awssdk.regions.Region;
1820
import software.amazon.awssdk.utils.Logger;
@@ -25,6 +27,7 @@
2527
import java.net.*;
2628
import java.nio.ByteBuffer;
2729
import software.amazon.awssdk.core.SdkBytes;
30+
import java.util.concurrent.CompletableFuture;
2831

2932
@RunWith(LocalstackTestRunner.class)
3033
public class BasicFeaturesSDKV2Test {
@@ -98,4 +101,17 @@ public void testSendSNSMessage() throws Exception {
98101
PublishResponse publishResponse = clientSNS.publish(publishRequest).get();
99102
Assert.assertNotNull(publishResponse.messageId());
100103
}
104+
105+
@Test
106+
public void testGetSsmParameter() throws Exception {
107+
// Test integration of ssm parameter with LocalStack using SDK v2
108+
109+
final String topicName = "test-t-"+UUID.randomUUID().toString();
110+
final SsmAsyncClient clientSsm = TestUtils.getClientSSMAsyncV2();
111+
CompletableFuture<PutParameterResponse> putParameterReponse = clientSsm.putParameter(PutParameterRequest.builder().name("testparameter").value("testvalue").build());
112+
CompletableFuture<GetParameterResponse> getParameterResponse = clientSsm.getParameter(GetParameterRequest.builder().name("testparameter").build());
113+
String parameterValue = getParameterResponse.get().parameter().value();
114+
Assert.assertNotNull(parameterValue);
115+
Assert.assertEquals("testvalue", parameterValue);
116+
}
101117
}

0 commit comments

Comments
 (0)