-
Notifications
You must be signed in to change notification settings - Fork 861
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
Add support for service-specific endpoint overrides without code changes. #5562
Conversation
…errides. Class-Level Changes: * DefaultServiceEndpointBuilder - Deprecated in favor of the new ClientEndpointProvider and AwsClientEndpointProvider * ClientEndpointProvider - An interface for resolving the client-level endpoint. This endpoint may be overridden by the request-level EndpointProvider. This joins the existing fleet of endpoint-related providers, like region providers, dualstack providers, and FIPS providers. * AwsClientEndpointProvider - An implementation of ClientEndpointProvider that checks the client configuration, environment and service metadata to determine the client endpoint. Field Changes: * Deprecated SdkClientOption.ENDPOINT and SdkClientOption.ENDPOINT_OVERRIDDEN in favor of a new SdkClientOption.CLIENT_ENDPOINT_PROVIDER. The new property allows updating both values in a single field. It was a necessary improvement so that these properties can stay in sync, reliably. * Deprecated SdkExecutionAttribute.CLIENT_ENDPOINT and SdkClientOption.ENDPOINT_OVERRIDDEN in favor of a new SdkInternalExecutionAttribute.CLIENT_ENDPOINT_PROVIDER. The new property exists for much the same reasons as the new SdkClientOption, but also provides an opportunity to hide these should-be-internal-to-the-SDK attributes.
…ndpoint providers. 1. Make clients set the SdkClientOption.CLIENT_ENDPOINT_PROVIDER when they are created. 2. Update the default AWS and SDK client builders to default the SdkClientOption.CLIENT_ENDPOINT_PROVIDERs so that old clients continue to work with the new core. Old clients versions won't support setting the endpoint with the new environment variable/system property/profile settings. This commit also includes EndpointSharedConfigTest which tests to make sure that the new ways of overriding the endpoint work for clients.
…ientEndpointProvider. These are the users that remain after the last commit: 1. RdsPresignInterceptors in RDS, Neptune and DocDB. It's unfortunate that these are pretty much copy+pasted classes, but that seems like a future problem to figure out. 2. S3Utilities 3. S3Presigner 4. PollyPresigner
…lientOptions and SdkExecutionAttributes to the new SdkClientOptions and SdkInternalExecutionAttribute.
4ddedd9
to
2a3cce2
Compare
...ws-core/src/main/java/software/amazon/awssdk/awscore/endpoint/AwsClientEndpointProvider.java
Show resolved
Hide resolved
So excited for this!! |
Co-authored-by: David Ho <70000000+davidh44@users.noreply.github.com>
...ws-core/src/main/java/software/amazon/awssdk/awscore/endpoint/AwsClientEndpointProvider.java
Outdated
Show resolved
Hide resolved
/** | ||
* This is the same as {@link #derivedBuilder(String, Class, ExecutionAttribute)}, but the real attribute is loaded | ||
* lazily at runtime. This is useful when the real attribute is in the same class hierarchy, to avoid initialization | ||
* order problems. | ||
*/ | ||
public static <T, U> DerivedAttributeBuilder<T, U> derivedBuilder(String name, | ||
@SuppressWarnings("unused") Class<T> attributeType, | ||
Supplier<ExecutionAttribute<U>> realAttribute) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a second to figure out what this meant! Just curious what happens if we do encounter this ordering issue with the other overload?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spotbugs complains about the dependency. I didn't test what happens if we ignore spotbugs. I suspect it could be a weird "no class def found" because of the cyclic static initialization dependency?
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
This adds support for this feature: https://docs.aws.amazon.com/sdkref/latest/guide/feature-ss-endpoints.html
The commit has been broken up into 6 commits, to hopefully simplify the code review:
Commit 1 - Made protected API changes in support of service-specific endpoint overrides.
This introduces new
ClientEndpointProvider
abstraction, which is used by clients to resolve the "default" endpoint for the client. The main implementation is the newAwsClientEndpointProvider
class, which checks the client-level endpoint override, environment variables, system properties and profile properties, in priority order. More information about what it checks is documented here.Other Protected API changes:
Commit 2 - Wires up the new AwsClientEndpointProvider for service clients
In this change, service client builders set the
AwsClientEndpointProvider
when they are created. This allows setting the service-specific environment variables, system settings and profile properties.We also update the default AWS client builder to set the
ClientEndpointProvider
, so that old client versions get the new CLIENT_ENDPOINT_PROVIDER option set. The default SDK client builder is also updated to use the new provider abstraction for endpoint overrides.This also includes EndpointSharedConfigTest, which tests to make sure that the new ways of overriding the endpoint work for clients.
Commit 3 - Wire up the new AwsClientEndpointProvider for non-clients
We want the new feature to work for other places that endpoints are derived. This commit includes updating S3Utilities, S3Presigner and PollyPresigner to also support the new way of specifying endpoint overrides.
We also update RdsPresignInterceptors in RDS, Neptune and DocDB to use the new AwsClientEndpointProvider. Here, we don't wire up support for the new environment-based endpoint overrides, because the endpoint in the presigned URL for these APIs needs to be the actual RDS endpoint URL, not overrides.
Commit 4 - Move users of the old SdkClientOptions and SdkExecutionAttributes over to the new settings
These changes are less interesting, and a bit tedious. In this, we change everywhere in the SDK that is using the old
SdkClientOption.ENDPOINT
,SdkClientOption.ENDPOINT_OVERRIDDEN
to the newSdkClientOption.CLIENT_ENDPOINT_PROVIDER
. We also update everywhere in the SDK we're using the oldSdkExecutionAttribute.CLIENT_ENDPOINT
andSdkClientOption.ENDPOINT_OVERRIDDEN
to the newSdkInternalExecutionAttribute.CLIENT_ENDPOINT_PROVIDER
.Commit 5 - CodeGen test updates
These are even less interesting. These are the codegen test files we changed in support of commit 2 above.
Commit 6 - Changelog Entry
Self-explanatory.