Skip to content

Added support for endpoint variants in endpoint metadata: FIPS and DUALSTACK. #2808

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

Closed
wants to merge 1 commit into from

Conversation

millems
Copy link
Contributor

@millems millems commented Oct 29, 2021

This adds the ability to resolve fips and dualstack endpoints with a "fips enabled" or "dualstack enabled" flag.

E.g.

URI fipsEndpoint =
    ServiceMetadata.of(S3Client.SERVICE_METADATA_ID)
                   .endpointFor(ServiceEndpointKey.builder()
                                                  .region(Region.US_WEST_2)
                                                  .tags(EndpointTag.FIPS)
                                                  .build());

The following public API changes were made:

  1. Added ServiceMetadata.endpointFor(ServiceEndpointKey)
  2. Added ServiceMetadata.signingRegion(ServiceEndpointKey)
  3. Added PartitionMetadata.hostname(PartitionEndpointKey)
  4. Added PartitionMetadata.dnsSuffix(PartitionEndpointKey)
  5. Added a generated EndpointTag class, which currently contains FIPS and DUALSTACK.
  6. Removed ServiceMetadata.computeEndpoint, because it shouldn't have ever been public, and no one should be using it.

The following module changes were made:

  1. Added regions-testing for verifying region resolution behavior that doesn't currently exist in the endpoints.json

Comment on lines 36 to 38
default String endpointPrefix() {
throw new UnsupportedOperationException();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add Javadoc for this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, meant to delete this.


@Override
public Set<EndpointTag> tags() {
return Collections.unmodifiableSet(tags);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, might consider wrapping it in the ctor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

@Override
public boolean equals(Object o) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test for hashcode and equals?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


@Override
public Set<EndpointTag> tags() {
return Collections.unmodifiableSet(tags);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, might be better to wrap it in the ctor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

*/
@SdkPublicApi
@Immutable
public interface ServiceEndpointKey {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need an interface since this looks like a data class? Same comment for PartitionEndpointKey

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to exclude this module from mvn release command and add it to the excluded import list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

import software.amazon.awssdk.utils.StringUtils;
import software.amazon.awssdk.utils.internal.CodegenNamingUtils;

public class EndpointTagGenerator implements PoetClass {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test to generate EndpointTag? It's hard to tell what EndpointTag looks like from codegen code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@millems millems force-pushed the millem/endpoint-tag-support branch 2 times, most recently from 7ee3e3b to 13b47a6 Compare November 2, 2021 19:58
Copy link
Contributor

@zoewangg zoewangg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a changelog entry?

Comment on lines +528 to +531
<exclude>software.amazon.awssdk.regions.ServiceMetadata</exclude>
<exclude>software.amazon.awssdk.regions.servicemetadata.*ServiceMetadata</exclude>
<exclude>software.amazon.awssdk.regions.DefaultServiceMetadata</exclude>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need to exclude them after METHOD_ABSTRACT_NOW_DEFAULT override is added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's being too picky about backwards-compatible. There weren't any actual breaking changes in these classes, since we added the implementation in the parent interface.


import static org.junit.Assert.*;

public class EndpointTagGeneratorTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meant to delete this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@@ -78,25 +107,6 @@ static ServiceMetadata of(String serviceEndpointPrefix) {
return metadata == null ? new DefaultServiceMetadata(serviceEndpointPrefix) : metadata;
}

default String computeEndpoint(String endpointPrefix,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a breaking change. Should we deprecate it instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm, saw it in the description. Can we mention it in the change log entry?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am almost certain that no one is using it. I'd much rather just delete it, because anyone using it is almost certainly doing it wrong.

@millems
Copy link
Contributor Author

millems commented Nov 2, 2021

I'll add a changelog entry when this is finalized. It won't be merged to master until the fips and dualstack changes are in place (actually using the tags).

…ALSTACK.

This adds the ability to resolve fips and dualstack endpoints with a "fips enabled" or "dualstack enabled" flag.

E.g.
```java
URI fipsEndpoint =
    ServiceMetadata.of(S3Client.SERVICE_METADATA_ID)
                   .endpointFor(ServiceEndpointKey.builder()
                                                  .region(Region.US_WEST_2)
                                                  .tags(EndpointTag.FIPS)
                                                  .build());
```

The following public API changes were made:
1. Added `ServiceMetadata.endpointFor(ServiceEndpointKey)`
2. Added `ServiceMetadata.signingRegion(ServiceEndpointKey)`
3. Added `PartitionMetadata.hostname(PartitionEndpointKey)`
4. Added `PartitionMetadata.dnsSuffix(PartitionEndpointKey)`
5. Added a generated `EndpointTag` class, which currently contains FIPS and DUALSTACK.
6. Removed `ServiceMetadata.computeEndpoint`, because it shouldn't have ever been public, and no one should be using it.

The following module changes were made:
1. Added `regions-testing` for verifying region resolution behavior that doesn't currently exist in the endpoints.json
@millems millems force-pushed the millem/endpoint-tag-support branch from 13b47a6 to 3f28c17 Compare November 2, 2021 20:38
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 2, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 20 Code Smells

88.3% 88.3% Coverage
2.7% 2.7% Duplication

@millems
Copy link
Contributor Author

millems commented Nov 2, 2021

Merged to branch endpoint-tag-staging.

@millems millems closed this Nov 3, 2021
millems added a commit that referenced this pull request Nov 3, 2021
This option can be used to make calls be invoked against AWS endpoints which return IPv6 records. This can also be enabled via the `AWS_USE_DUALSTACK_ENDPOINT` environment variable, `aws.useDualstackEndpoint` system property, or the `use_dualstack_endpoint` profile file property:

1. This PR builds on top of the 'endpoint variants' #2808, by specifying the DUALSTACK endpoint variant whenever the customer requests dualstack to be enabled.
2. The bulk of the files in this PR are addressing the fact that we already have service configuration for enabling dualstack for S3 and S3 control. These existing options have been deprecated in favor of the new option that works for all services.
millems added a commit that referenced this pull request Nov 3, 2021
This option can be used to make calls be invoked against AWS endpoints which return IPv6 records. This can also be enabled via the `AWS_USE_DUALSTACK_ENDPOINT` environment variable, `aws.useDualstackEndpoint` system property, or the `use_dualstack_endpoint` profile file property:

1. This PR builds on top of the 'endpoint variants' #2808, by specifying the DUALSTACK endpoint variant whenever the customer requests dualstack to be enabled.
2. The bulk of the files in this PR are addressing the fact that we already have service configuration for enabling dualstack for S3 and S3 control. These existing options have been deprecated in favor of the new option that works for all services.
millems added a commit that referenced this pull request Nov 3, 2021
This option can be used to make calls be invoked against AWS endpoints which return IPv6 records. This can also be enabled via the `AWS_USE_DUALSTACK_ENDPOINT` environment variable, `aws.useDualstackEndpoint` system property, or the `use_dualstack_endpoint` profile file property:

1. This PR builds on top of the 'endpoint variants' #2808, by specifying the DUALSTACK endpoint variant whenever the customer requests dualstack to be enabled.
2. The bulk of the files in this PR are addressing the fact that we already have service configuration for enabling dualstack for S3 and S3 control. These existing options have been deprecated in favor of the new option that works for all services.
millems added a commit that referenced this pull request Nov 9, 2021
This option can be used to make calls be invoked against AWS endpoints which return IPv6 records. This can also be enabled via the `AWS_USE_DUALSTACK_ENDPOINT` environment variable, `aws.useDualstackEndpoint` system property, or the `use_dualstack_endpoint` profile file property:

1. This PR builds on top of the 'endpoint variants' #2808, by specifying the DUALSTACK endpoint variant whenever the customer requests dualstack to be enabled.
2. The bulk of the files in this PR are addressing the fact that we already have service configuration for enabling dualstack for S3 and S3 control. These existing options have been deprecated in favor of the new option that works for all services.
millems added a commit that referenced this pull request Nov 10, 2021
* Added support for endpoint variants in endpoint metadata: FIPS and DUALSTACK.

This adds the ability to resolve fips and dualstack endpoints with a "fips enabled" or "dualstack enabled" flag.

E.g.
```java
URI fipsEndpoint =
    ServiceMetadata.of(S3Client.SERVICE_METADATA_ID)
                   .endpointFor(ServiceEndpointKey.builder()
                                                  .region(Region.US_WEST_2)
                                                  .tags(EndpointTag.FIPS)
                                                  .build());
```

The following public API changes were made:
1. Added `ServiceMetadata.endpointFor(ServiceEndpointKey)`
2. Added `ServiceMetadata.signingRegion(ServiceEndpointKey)`
3. Added `PartitionMetadata.hostname(PartitionEndpointKey)`
4. Added `PartitionMetadata.dnsSuffix(PartitionEndpointKey)`
5. Added a generated `EndpointTag` class, which currently contains FIPS and DUALSTACK.
6. Removed `ServiceMetadata.computeEndpoint`, because it shouldn't have ever been public, and no one should be using it.

The following module changes were made:
1. Added `regions-testing` for verifying region resolution behavior that doesn't currently exist in the endpoints.json

* Added a new `dualstackEnabled` property to every client builder. (#2818)

This option can be used to make calls be invoked against AWS endpoints which return IPv6 records. This can also be enabled via the `AWS_USE_DUALSTACK_ENDPOINT` environment variable, `aws.useDualstackEndpoint` system property, or the `use_dualstack_endpoint` profile file property:

1. This PR builds on top of the 'endpoint variants' #2808, by specifying the DUALSTACK endpoint variant whenever the customer requests dualstack to be enabled.
2. The bulk of the files in this PR are addressing the fact that we already have service configuration for enabling dualstack for S3 and S3 control. These existing options have been deprecated in favor of the new option that works for all services.

* Added support for enabling FIPS endpoints. (#2826)

This option can be used to make calls be invoked against FIPS-compliant AWS endpoints. This can also be enabled via the AWS_USE_FIPS_ENDPOINT environment variable, aws.useFipsEndpoint system property, or the use_fips_endpoint profile file property:
@millems millems deleted the millem/endpoint-tag-support branch October 19, 2022 19:38
aws-sdk-java-automation added a commit that referenced this pull request Nov 22, 2023
…034aaea97

Pull request: release <- staging/b49e4374-53b8-4a8d-8ee6-fbc034aaea97
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants