Skip to content

Commit 8b1028a

Browse files
authored
aws: limit dual-stack to allowed regions (#587)
Add config with the set of regions where dual-stack endpoints are actually available. This needs to be done in addition to checking if the various services actually support it.
1 parent a12ac75 commit 8b1028a

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

iep-spring-aws2/src/main/java/com/netflix/iep/aws2/AwsClientFactory.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,13 @@ public <T> T newInstance(String name, Class<T> cls, String accountId, Optional<R
373373
try {
374374
Config cfg = getConfig(name, cls);
375375
Config clientConfig = cfg.getConfig("client");
376+
Region selectedRegion = region.orElseGet(() -> chooseRegion(name, cls));
376377
SdkHttpService service = createSyncHttpService(clientConfig);
377378
Method builderMethod = cls.getMethod("builder");
378379
AwsClientBuilder<?, ?> builder = ((AwsClientBuilder<?, ?>) builderMethod.invoke(null))
379380
.credentialsProvider(createCredentialsProvider(cfg.getConfig("credentials"), accountId, service))
380-
.region(region.orElseGet(() -> chooseRegion(name, cls)))
381-
.dualstackEnabled(cfg.getBoolean("dualstack"))
381+
.region(selectedRegion)
382+
.dualstackEnabled(shouldUseDualstack(cfg, selectedRegion))
382383
.overrideConfiguration(createClientConfig(clientConfig));
383384
AttributeMap attributeMap = getSdkHttpConfigurationOptions(clientConfig);
384385

@@ -397,6 +398,11 @@ public <T> T newInstance(String name, Class<T> cls, String accountId, Optional<R
397398
}
398399
}
399400

401+
private boolean shouldUseDualstack(Config cfg, Region region) {
402+
return cfg.getBoolean("dualstack")
403+
&& cfg.getStringList("dualstack-regions").contains(region.id());
404+
}
405+
400406
/**
401407
* Get a shared instance of an AWS client of the specified type. The name of the config
402408
* block will be based on the package for the class name. For example, if requesting an

iep-spring-aws2/src/main/resources/reference.conf

+12
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ netflix.iep.aws {
4343
// Should dualstack be enabled for the client?
4444
// https://docs.aws.amazon.com/vpc/latest/userguide/aws-ipv6-support.html
4545
dualstack = false
46+
47+
// Unfortunately, AWS doesn't have consistent support for dualstack across all
48+
// regions. Add list of supported regions.
49+
// https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Using_Endpoints.html#ipv6
50+
dualstack-regions = [
51+
"ap-south-1",
52+
"eu-west-1",
53+
"sa-east-1",
54+
"us-east-1",
55+
"us-east-2",
56+
"us-west-2"
57+
]
4658
}
4759

4860
// Overrides for services that support IPv6 to use dualstack

0 commit comments

Comments
 (0)