Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get region from env variables or default #3556

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ public class LocalStackContainer extends GenericContainer<LocalStackContainer> {

private static final String DEFAULT_TAG = "0.11.2";

private static final String DEFAULT_REGION = "us-east-1";

@Deprecated
public static final String VERSION = DEFAULT_TAG;


/**
* Whether or to assume that all APIs run on different ports (when <code>true</code>) or are
* exposed on a single port (<code>false</code>). From the Localstack README:
Expand Down Expand Up @@ -311,7 +314,7 @@ public String getSecretKey() {
* @return a default region
*/
public String getRegion() {
return "us-east-1";
return this.getEnvMap().getOrDefault("DEFAULT_REGION", DEFAULT_REGION);
}

public interface EnabledService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,22 @@ private String runAwsCliAgainstDockerNetworkContainer(String command) throws Exc
return logs;
}
}

public static class WithRegion {

// with_region {
private static String region = "eu-west-1";
@ClassRule
public static LocalStackContainer localstack = new LocalStackContainer(LOCALSTACK_IMAGE)
eddumelendez marked this conversation as resolved.
Show resolved Hide resolved
.withEnv("DEFAULT_REGION", region)
.withServices(S3);
eddumelendez marked this conversation as resolved.
Show resolved Hide resolved
// }

@Test
public void s3EndpointHasProperRegion() throws IOException {
final AwsClientBuilder.EndpointConfiguration endpointConfiguration = localstack.getEndpointConfiguration(S3);
assertEquals("The endpoint configuration has right region", region, endpointConfiguration.getSigningRegion());

}
}
}