Skip to content
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

apply path-style-access-enabled config to CRT client #872

Merged
merged 2 commits into from
Dec 8, 2023

Conversation

chrisrhut
Copy link
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Apply the path-style-access-enabled S3 config property in the S3CrtAsyncClientAutoConfiguration

💡 Motivation and Context

The standard S3 configuration allows you to configure "path style access" via property config. AWS has added this to the CRT client configuration as of version 2.20.42 per this thread. It would be great to have this option available in the auto configuration for the CRT client.

💚 How did you test it?

Reflection-driven unit test and empirical localhost testing.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • I updated reference documentation to reflect the change
  • All tests passing
  • No breaking changes

🔮 Next steps

@github-actions github-actions bot added the component: s3 S3 integration related issue label Aug 23, 2023
contextRunner.withPropertyValues().run(context -> {
S3AsyncClient client = context.getBean(S3AsyncClient.class);
S3AsyncClient delegate = (S3AsyncClient) ReflectionTestUtils.getField(client, "delegate");
SdkClientConfiguration clientConfiguration = (SdkClientConfiguration) ReflectionTestUtils.getField(delegate, "clientConfiguration");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If anybody can think of a way to accomplish this without the double reflection field access, I would love to do this more eloquently!

@@ -66,6 +66,7 @@ S3AsyncClient s3AsyncClient(AwsCredentialsProvider credentialsProvider) {
.region(this.awsClientBuilderConfigurer.resolveRegion(this.properties));
Optional.ofNullable(this.awsProperties.getEndpoint()).ifPresent(builder::endpointOverride);
Optional.ofNullable(this.properties.getEndpoint()).ifPresent(builder::endpointOverride);
Optional.ofNullable(this.properties.getPathStyleAccessEnabled()).ifPresent(builder::forcePathStyle);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is is actually the same? "forcePathStyle" and "pathStyleAccessEnabled"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a lot of code like this in the SDK codebase that heavily implies they are the same. I am definitely willing to be proven wrong but I couldn't find any other mapping for the option that does the same thing across the the SDK.

    private AttributeMap createClientContextParams() {
        AttributeMap.Builder params = AttributeMap.builder();

        params.put(S3ClientContextParams.USE_ARN_REGION, s3Configuration.useArnRegionEnabled());
        params.put(S3ClientContextParams.DISABLE_MULTI_REGION_ACCESS_POINTS,
                   !s3Configuration.multiRegionEnabled());
        params.put(S3ClientContextParams.FORCE_PATH_STYLE, s3Configuration.pathStyleAccessEnabled());
        params.put(S3ClientContextParams.ACCELERATE, s3Configuration.accelerateModeEnabled());
        return params.build();
    }

Second example

@maciejwalkowiak maciejwalkowiak added the status: waiting-for-feedback Waiting for feedback from issuer label Oct 23, 2023
@maciejwalkowiak maciejwalkowiak merged commit a45705b into awspring:main Dec 8, 2023
4 checks passed
@maciejwalkowiak maciejwalkowiak added this to the 3.1.0 milestone Dec 8, 2023
@maciejwalkowiak maciejwalkowiak removed the status: waiting-for-feedback Waiting for feedback from issuer label Dec 8, 2023
maciejwalkowiak added a commit that referenced this pull request Dec 10, 2023
Co-authored-by: Maciej Walkowiak <walkowiak.maciej@yahoo.com>
maciejwalkowiak added a commit that referenced this pull request Dec 10, 2023
Co-authored-by: Maciej Walkowiak <walkowiak.maciej@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: s3 S3 integration related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants