-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Automatically guess EC2 endpoint based on metadata #27924
Copy link
Copy link
Closed
Labels
:Distributed/Discovery-PluginsAnything related to our integration plugins with EC2, GCP and AzureAnything related to our integration plugins with EC2, GCP and Azure>enhancementTeam:DistributedMeta label for distributed team.Meta label for distributed team.help wantedadoptmeadoptme
Description
While I was working on #27464, I came to this part of the AWS SDK code:
/**
* Sets the endpoint configuration (service endpoint & signing region) to be used for requests. If neither region {@link #setRegion(String)}
* or endpoint configuration are explicitly provided in the builder the {@link #DEFAULT_REGION_PROVIDER} is consulted.
*
* <p><b>Only use this if using a non-standard service endpoint - the recommended approach for configuring a client is to use {@link #setRegion(String)}</b>
*
* @param endpointConfiguration The endpointConfiguration to use
*/
public final void setEndpointConfiguration(EndpointConfiguration endpointConfiguration) {
withEndpointConfiguration(endpointConfiguration);
}Important part is:
Only use this if using a non-standard service endpoint - the recommended approach for configuring a client is to use
setRegion(String)
Which basically means that we should revisit the decision we made in #22758 and remove endpoint and reintroduce region.
Creating a AWS EC2 client would be as simple as:
AmazonEC2ClientBuilder builder = AmazonEC2ClientBuilder.standard()
.withRegion(region)
.withCredentials(buildCredentials(logger, settings))
.withClientConfiguration(buildConfiguration(logger, settings));Even better, we can actually retrieve automatically the region if not explicitly set from the metadata instance by calling:
String region = new InstanceMetadataRegionProvider().getRegion();Which would simplify even more the usage of the plugin as people won't normally have to define anything but:
discovery.zen.hosts_provider: ec2
Authentication is done using IAM Role credentials by default.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
:Distributed/Discovery-PluginsAnything related to our integration plugins with EC2, GCP and AzureAnything related to our integration plugins with EC2, GCP and Azure>enhancementTeam:DistributedMeta label for distributed team.Meta label for distributed team.help wantedadoptmeadoptme
Type
Fields
Give feedbackNo fields configured for issues without a type.