Discovery EC2: Remove region setting (#23991)
We have both endpoint and region settings. Region was removed from s3 to simplify configuration. This is the ec2 equivalent. closes #22758
This commit is contained in:
parent
05e2ea1aef
commit
83ba677e7f
|
@ -39,3 +39,6 @@ See {plugins}/repository-azure-usage.html#repository-azure-repository-settings[A
|
||||||
==== EC2 Discovery plugin
|
==== EC2 Discovery plugin
|
||||||
|
|
||||||
* Specifying ec2 signer type has been removed, including `cloud.aws.signer` and `cloud.aws.ec2.signer`.
|
* Specifying ec2 signer type has been removed, including `cloud.aws.signer` and `cloud.aws.ec2.signer`.
|
||||||
|
|
||||||
|
* The region setting has been removed. This includes the settings `cloud.aws.region`
|
||||||
|
and `cloud.aws.ec2.region`. Instead, specify the full endpoint.
|
||||||
|
|
|
@ -76,11 +76,6 @@ interface AwsEc2Service {
|
||||||
*/
|
*/
|
||||||
Setting<SecureString> PROXY_PASSWORD_SETTING = new Setting<>("cloud.aws.proxy.password", "", SecureString::new,
|
Setting<SecureString> PROXY_PASSWORD_SETTING = new Setting<>("cloud.aws.proxy.password", "", SecureString::new,
|
||||||
Property.NodeScope, Property.Filtered, Property.Shared, Property.Deprecated);
|
Property.NodeScope, Property.Filtered, Property.Shared, Property.Deprecated);
|
||||||
/**
|
|
||||||
* cloud.aws.region: Region. Shared with repository-s3 plugin
|
|
||||||
*/
|
|
||||||
Setting<String> REGION_SETTING =
|
|
||||||
new Setting<>("cloud.aws.region", "", s -> s.toLowerCase(Locale.ROOT), Property.NodeScope, Property.Shared, Property.Deprecated);
|
|
||||||
/**
|
/**
|
||||||
* cloud.aws.read_timeout: Socket read timeout. Shared with repository-s3 plugin
|
* cloud.aws.read_timeout: Socket read timeout. Shared with repository-s3 plugin
|
||||||
*/
|
*/
|
||||||
|
@ -136,12 +131,6 @@ interface AwsEc2Service {
|
||||||
*/
|
*/
|
||||||
Setting<SecureString> PROXY_PASSWORD_SETTING = new Setting<>("cloud.aws.ec2.proxy.password", AwsEc2Service.PROXY_PASSWORD_SETTING,
|
Setting<SecureString> PROXY_PASSWORD_SETTING = new Setting<>("cloud.aws.ec2.proxy.password", AwsEc2Service.PROXY_PASSWORD_SETTING,
|
||||||
SecureString::new, Property.NodeScope, Property.Filtered, Property.Deprecated);
|
SecureString::new, Property.NodeScope, Property.Filtered, Property.Deprecated);
|
||||||
/**
|
|
||||||
* cloud.aws.ec2.region: Region specific for EC2 API calls. Defaults to cloud.aws.region.
|
|
||||||
* @see AwsEc2Service#REGION_SETTING
|
|
||||||
*/
|
|
||||||
Setting<String> REGION_SETTING = new Setting<>("cloud.aws.ec2.region", AwsEc2Service.REGION_SETTING,
|
|
||||||
s -> s.toLowerCase(Locale.ROOT), Property.NodeScope, Property.Deprecated);
|
|
||||||
/**
|
/**
|
||||||
* cloud.aws.ec2.endpoint: Endpoint. If not set, endpoint will be guessed based on region setting.
|
* cloud.aws.ec2.endpoint: Endpoint. If not set, endpoint will be guessed based on region setting.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -131,72 +131,6 @@ class AwsEc2ServiceImpl extends AbstractComponent implements AwsEc2Service, Clos
|
||||||
if (DISCOVERY_EC2.ENDPOINT_SETTING.exists(settings) || CLOUD_EC2.ENDPOINT_SETTING.exists(settings)) {
|
if (DISCOVERY_EC2.ENDPOINT_SETTING.exists(settings) || CLOUD_EC2.ENDPOINT_SETTING.exists(settings)) {
|
||||||
endpoint = DISCOVERY_EC2.ENDPOINT_SETTING.get(settings);
|
endpoint = DISCOVERY_EC2.ENDPOINT_SETTING.get(settings);
|
||||||
logger.debug("using explicit ec2 endpoint [{}]", endpoint);
|
logger.debug("using explicit ec2 endpoint [{}]", endpoint);
|
||||||
} else if (REGION_SETTING.exists(settings) || CLOUD_EC2.REGION_SETTING.exists(settings)) {
|
|
||||||
final String region = CLOUD_EC2.REGION_SETTING.get(settings);
|
|
||||||
switch (region) {
|
|
||||||
case "us-east-1":
|
|
||||||
case "us-east":
|
|
||||||
endpoint = "ec2.us-east-1.amazonaws.com";
|
|
||||||
break;
|
|
||||||
case "us-east-2":
|
|
||||||
endpoint = "ec2.us-east-2.amazonaws.com";
|
|
||||||
break;
|
|
||||||
case "us-west":
|
|
||||||
case "us-west-1":
|
|
||||||
endpoint = "ec2.us-west-1.amazonaws.com";
|
|
||||||
break;
|
|
||||||
case "us-west-2":
|
|
||||||
endpoint = "ec2.us-west-2.amazonaws.com";
|
|
||||||
break;
|
|
||||||
case "ap-southeast":
|
|
||||||
case "ap-southeast-1":
|
|
||||||
endpoint = "ec2.ap-southeast-1.amazonaws.com";
|
|
||||||
break;
|
|
||||||
case "ap-south":
|
|
||||||
case "ap-south-1":
|
|
||||||
endpoint = "ec2.ap-south-1.amazonaws.com";
|
|
||||||
break;
|
|
||||||
case "us-gov-west":
|
|
||||||
case "us-gov-west-1":
|
|
||||||
endpoint = "ec2.us-gov-west-1.amazonaws.com";
|
|
||||||
break;
|
|
||||||
case "ap-southeast-2":
|
|
||||||
endpoint = "ec2.ap-southeast-2.amazonaws.com";
|
|
||||||
break;
|
|
||||||
case "ap-northeast":
|
|
||||||
case "ap-northeast-1":
|
|
||||||
endpoint = "ec2.ap-northeast-1.amazonaws.com";
|
|
||||||
break;
|
|
||||||
case "ap-northeast-2":
|
|
||||||
endpoint = "ec2.ap-northeast-2.amazonaws.com";
|
|
||||||
break;
|
|
||||||
case "eu-west":
|
|
||||||
case "eu-west-1":
|
|
||||||
endpoint = "ec2.eu-west-1.amazonaws.com";
|
|
||||||
break;
|
|
||||||
case "eu-west-2":
|
|
||||||
endpoint = "ec2.eu-west-2.amazonaws.com";
|
|
||||||
break;
|
|
||||||
case "eu-central":
|
|
||||||
case "eu-central-1":
|
|
||||||
endpoint = "ec2.eu-central-1.amazonaws.com";
|
|
||||||
break;
|
|
||||||
case "sa-east":
|
|
||||||
case "sa-east-1":
|
|
||||||
endpoint = "ec2.sa-east-1.amazonaws.com";
|
|
||||||
break;
|
|
||||||
case "cn-north":
|
|
||||||
case "cn-north-1":
|
|
||||||
endpoint = "ec2.cn-north-1.amazonaws.com.cn";
|
|
||||||
break;
|
|
||||||
case "ca-central":
|
|
||||||
case "ca-central-1":
|
|
||||||
endpoint = "ec2.ca-central-1.amazonaws.com";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]");
|
|
||||||
}
|
|
||||||
logger.debug("using ec2 region [{}], with endpoint [{}]", region, endpoint);
|
|
||||||
}
|
}
|
||||||
return endpoint;
|
return endpoint;
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,6 @@ public class Ec2DiscoveryPlugin extends Plugin implements DiscoveryPlugin, Close
|
||||||
AwsEc2Service.PROXY_PORT_SETTING,
|
AwsEc2Service.PROXY_PORT_SETTING,
|
||||||
AwsEc2Service.PROXY_USERNAME_SETTING,
|
AwsEc2Service.PROXY_USERNAME_SETTING,
|
||||||
AwsEc2Service.PROXY_PASSWORD_SETTING,
|
AwsEc2Service.PROXY_PASSWORD_SETTING,
|
||||||
AwsEc2Service.REGION_SETTING,
|
|
||||||
AwsEc2Service.READ_TIMEOUT,
|
AwsEc2Service.READ_TIMEOUT,
|
||||||
// Register EC2 specific settings: cloud.aws.ec2
|
// Register EC2 specific settings: cloud.aws.ec2
|
||||||
AwsEc2Service.CLOUD_EC2.KEY_SETTING,
|
AwsEc2Service.CLOUD_EC2.KEY_SETTING,
|
||||||
|
@ -137,7 +136,6 @@ public class Ec2DiscoveryPlugin extends Plugin implements DiscoveryPlugin, Close
|
||||||
AwsEc2Service.CLOUD_EC2.PROXY_PORT_SETTING,
|
AwsEc2Service.CLOUD_EC2.PROXY_PORT_SETTING,
|
||||||
AwsEc2Service.CLOUD_EC2.PROXY_USERNAME_SETTING,
|
AwsEc2Service.CLOUD_EC2.PROXY_USERNAME_SETTING,
|
||||||
AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING,
|
AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING,
|
||||||
AwsEc2Service.CLOUD_EC2.REGION_SETTING,
|
|
||||||
AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING,
|
AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING,
|
||||||
AwsEc2Service.CLOUD_EC2.READ_TIMEOUT,
|
AwsEc2Service.CLOUD_EC2.READ_TIMEOUT,
|
||||||
// Register EC2 discovery settings: discovery.ec2
|
// Register EC2 discovery settings: discovery.ec2
|
||||||
|
|
|
@ -210,41 +210,4 @@ public class AwsEc2ServiceImplTests extends ESTestCase {
|
||||||
AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING
|
AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRegionWithAwsSettings() {
|
|
||||||
Settings settings = Settings.builder()
|
|
||||||
.put(AwsEc2Service.REGION_SETTING.getKey(), randomFrom("eu-west", "eu-west-1"))
|
|
||||||
.build();
|
|
||||||
String endpoint = AwsEc2ServiceImpl.findEndpoint(logger, settings);
|
|
||||||
assertThat(endpoint, is("ec2.eu-west-1.amazonaws.com"));
|
|
||||||
assertSettingDeprecationsAndWarnings(new Setting<?>[] {
|
|
||||||
AwsEc2Service.REGION_SETTING
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testRegionWithAwsAndEc2Settings() {
|
|
||||||
Settings settings = Settings.builder()
|
|
||||||
.put(AwsEc2Service.REGION_SETTING.getKey(), randomFrom("eu-west", "eu-west-1"))
|
|
||||||
.put(AwsEc2Service.CLOUD_EC2.REGION_SETTING.getKey(), randomFrom("us-west", "us-west-1"))
|
|
||||||
.build();
|
|
||||||
String endpoint = AwsEc2ServiceImpl.findEndpoint(logger, settings);
|
|
||||||
assertThat(endpoint, is("ec2.us-west-1.amazonaws.com"));
|
|
||||||
assertSettingDeprecationsAndWarnings(new Setting<?>[] {
|
|
||||||
AwsEc2Service.REGION_SETTING,
|
|
||||||
AwsEc2Service.CLOUD_EC2.REGION_SETTING
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testInvalidRegion() {
|
|
||||||
Settings settings = Settings.builder()
|
|
||||||
.put(AwsEc2Service.REGION_SETTING.getKey(), "does-not-exist")
|
|
||||||
.build();
|
|
||||||
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> {
|
|
||||||
AwsEc2ServiceImpl.findEndpoint(logger, settings);
|
|
||||||
});
|
|
||||||
assertThat(e.getMessage(), containsString("No automatic endpoint could be derived from region"));
|
|
||||||
assertSettingDeprecationsAndWarnings(new Setting<?>[] {
|
|
||||||
AwsEc2Service.REGION_SETTING
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ public class Ec2DiscoverySettingsTests extends ESTestCase {
|
||||||
.put(AwsEc2Service.PROXY_PORT_SETTING.getKey(), 10000)
|
.put(AwsEc2Service.PROXY_PORT_SETTING.getKey(), 10000)
|
||||||
.put(AwsEc2Service.PROXY_USERNAME_SETTING.getKey(), "global-proxy-username")
|
.put(AwsEc2Service.PROXY_USERNAME_SETTING.getKey(), "global-proxy-username")
|
||||||
.put(AwsEc2Service.PROXY_PASSWORD_SETTING.getKey(), "global-proxy-password")
|
.put(AwsEc2Service.PROXY_PASSWORD_SETTING.getKey(), "global-proxy-password")
|
||||||
.put(AwsEc2Service.REGION_SETTING.getKey(), "global-region")
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private static final Settings EC2 = Settings.builder()
|
private static final Settings EC2 = Settings.builder()
|
||||||
|
@ -48,7 +47,6 @@ public class Ec2DiscoverySettingsTests extends ESTestCase {
|
||||||
.put(AwsEc2Service.CLOUD_EC2.PROXY_PORT_SETTING.getKey(), 20000)
|
.put(AwsEc2Service.CLOUD_EC2.PROXY_PORT_SETTING.getKey(), 20000)
|
||||||
.put(AwsEc2Service.CLOUD_EC2.PROXY_USERNAME_SETTING.getKey(), "ec2-proxy-username")
|
.put(AwsEc2Service.CLOUD_EC2.PROXY_USERNAME_SETTING.getKey(), "ec2-proxy-username")
|
||||||
.put(AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING.getKey(), "ec2-proxy-password")
|
.put(AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING.getKey(), "ec2-proxy-password")
|
||||||
.put(AwsEc2Service.CLOUD_EC2.REGION_SETTING.getKey(), "ec2-region")
|
|
||||||
.put(AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING.getKey(), "ec2-endpoint")
|
.put(AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING.getKey(), "ec2-endpoint")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -64,7 +62,6 @@ public class Ec2DiscoverySettingsTests extends ESTestCase {
|
||||||
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_PORT_SETTING.get(nodeSettings), is(10000));
|
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_PORT_SETTING.get(nodeSettings), is(10000));
|
||||||
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_USERNAME_SETTING.get(nodeSettings), is("global-proxy-username"));
|
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_USERNAME_SETTING.get(nodeSettings), is("global-proxy-username"));
|
||||||
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING.get(nodeSettings), is("global-proxy-password"));
|
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING.get(nodeSettings), is("global-proxy-password"));
|
||||||
assertThat(AwsEc2Service.CLOUD_EC2.REGION_SETTING.get(nodeSettings), is("global-region"));
|
|
||||||
assertThat(AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING.get(nodeSettings), isEmptyString());
|
assertThat(AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING.get(nodeSettings), isEmptyString());
|
||||||
assertSettingDeprecationsAndWarnings(new Setting<?>[] {
|
assertSettingDeprecationsAndWarnings(new Setting<?>[] {
|
||||||
AwsEc2Service.KEY_SETTING,
|
AwsEc2Service.KEY_SETTING,
|
||||||
|
@ -74,7 +71,6 @@ public class Ec2DiscoverySettingsTests extends ESTestCase {
|
||||||
AwsEc2Service.PROXY_PORT_SETTING,
|
AwsEc2Service.PROXY_PORT_SETTING,
|
||||||
AwsEc2Service.PROXY_USERNAME_SETTING,
|
AwsEc2Service.PROXY_USERNAME_SETTING,
|
||||||
AwsEc2Service.PROXY_PASSWORD_SETTING,
|
AwsEc2Service.PROXY_PASSWORD_SETTING,
|
||||||
AwsEc2Service.REGION_SETTING
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +86,6 @@ public class Ec2DiscoverySettingsTests extends ESTestCase {
|
||||||
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_PORT_SETTING.get(nodeSettings), is(20000));
|
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_PORT_SETTING.get(nodeSettings), is(20000));
|
||||||
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_USERNAME_SETTING.get(nodeSettings), is("ec2-proxy-username"));
|
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_USERNAME_SETTING.get(nodeSettings), is("ec2-proxy-username"));
|
||||||
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING.get(nodeSettings), is("ec2-proxy-password"));
|
assertThat(AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING.get(nodeSettings), is("ec2-proxy-password"));
|
||||||
assertThat(AwsEc2Service.CLOUD_EC2.REGION_SETTING.get(nodeSettings), is("ec2-region"));
|
|
||||||
assertThat(AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING.get(nodeSettings), is("ec2-endpoint"));
|
assertThat(AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING.get(nodeSettings), is("ec2-endpoint"));
|
||||||
assertSettingDeprecationsAndWarnings(new Setting<?>[] {
|
assertSettingDeprecationsAndWarnings(new Setting<?>[] {
|
||||||
AwsEc2Service.KEY_SETTING,
|
AwsEc2Service.KEY_SETTING,
|
||||||
|
@ -100,7 +95,6 @@ public class Ec2DiscoverySettingsTests extends ESTestCase {
|
||||||
AwsEc2Service.PROXY_PORT_SETTING,
|
AwsEc2Service.PROXY_PORT_SETTING,
|
||||||
AwsEc2Service.PROXY_USERNAME_SETTING,
|
AwsEc2Service.PROXY_USERNAME_SETTING,
|
||||||
AwsEc2Service.PROXY_PASSWORD_SETTING,
|
AwsEc2Service.PROXY_PASSWORD_SETTING,
|
||||||
AwsEc2Service.REGION_SETTING,
|
|
||||||
AwsEc2Service.CLOUD_EC2.KEY_SETTING,
|
AwsEc2Service.CLOUD_EC2.KEY_SETTING,
|
||||||
AwsEc2Service.CLOUD_EC2.SECRET_SETTING,
|
AwsEc2Service.CLOUD_EC2.SECRET_SETTING,
|
||||||
AwsEc2Service.CLOUD_EC2.PROTOCOL_SETTING,
|
AwsEc2Service.CLOUD_EC2.PROTOCOL_SETTING,
|
||||||
|
@ -108,7 +102,6 @@ public class Ec2DiscoverySettingsTests extends ESTestCase {
|
||||||
AwsEc2Service.CLOUD_EC2.PROXY_PORT_SETTING,
|
AwsEc2Service.CLOUD_EC2.PROXY_PORT_SETTING,
|
||||||
AwsEc2Service.CLOUD_EC2.PROXY_USERNAME_SETTING,
|
AwsEc2Service.CLOUD_EC2.PROXY_USERNAME_SETTING,
|
||||||
AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING,
|
AwsEc2Service.CLOUD_EC2.PROXY_PASSWORD_SETTING,
|
||||||
AwsEc2Service.CLOUD_EC2.REGION_SETTING,
|
|
||||||
AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING
|
AwsEc2Service.CLOUD_EC2.ENDPOINT_SETTING
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue