File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
main/java/org/testcontainers/containers/localstack
test/java/org/testcontainers/containers/localstack Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ public class LocalStackContainer extends GenericContainer<LocalStackContainer> {
4545
4646 private static final String DEFAULT_TAG = "0.11.2" ;
4747
48+ private static final String DEFAULT_REGION = "us-east-1" ;
49+
4850 @ Deprecated
4951 public static final String VERSION = DEFAULT_TAG ;
5052
@@ -311,7 +313,7 @@ public String getSecretKey() {
311313 * @return a default region
312314 */
313315 public String getRegion () {
314- return "us-east-1" ;
316+ return this . getEnvMap (). getOrDefault ( "DEFAULT_REGION" , DEFAULT_REGION ) ;
315317 }
316318
317319 public interface EnabledService {
Original file line number Diff line number Diff line change 11package org .testcontainers .containers .localstack ;
22
3+ import com .amazonaws .client .builder .AwsClientBuilder ;
34import com .amazonaws .services .kms .AWSKMS ;
45import com .amazonaws .services .kms .AWSKMSClientBuilder ;
56import com .amazonaws .services .kms .model .CreateKeyRequest ;
@@ -286,4 +287,29 @@ private String runAwsCliAgainstDockerNetworkContainer(String command) throws Exc
286287 return logs ;
287288 }
288289 }
290+
291+ public static class WithRegion {
292+
293+ // with_region {
294+ private static String region = "eu-west-1" ;
295+
296+ @ ClassRule
297+ public static LocalStackContainer localstack = new LocalStackContainer (LocalstackTestImages .LOCALSTACK_IMAGE )
298+ .withEnv ("DEFAULT_REGION" , region )
299+ .withServices (Service .S3 );
300+
301+ // }
302+
303+ @ Test
304+ public void s3EndpointHasProperRegion () {
305+ final AwsClientBuilder .EndpointConfiguration endpointConfiguration = localstack .getEndpointConfiguration (
306+ Service .S3
307+ );
308+ assertEquals (
309+ "The endpoint configuration has right region" ,
310+ region ,
311+ endpointConfiguration .getSigningRegion ()
312+ );
313+ }
314+ }
289315}
You can’t perform that action at this time.
0 commit comments