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

Updated Code samples to AWS SDK 2.x #63

Merged
merged 6 commits into from
Jul 27, 2022
Merged

Conversation

arunx2
Copy link
Contributor

@arunx2 arunx2 commented Apr 27, 2022

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@arunx2
Copy link
Contributor Author

arunx2 commented Jul 7, 2022

Can we merge this PR?

@dblock
Copy link
Contributor

dblock commented Jul 14, 2022

Came here to update the same docs!

First, https://github.com/awsdocs/aws-request-signing-apache-interceptor is not maintained, I am working on getting it archived. Evidenced by awsdocs/aws-request-signing-apache-interceptor#1 and awsdocs/aws-request-signing-apache-interceptor#2. It was an attempt at resurrecting the one in awslabs, but didn't get proper ownership.

I think we should stop copy-pasting AwsRequestSigningApacheInterceptor code. The one in the attached zip has a few bugs (e.g. acm19/aws-request-signing-apache-interceptor#38).

There's now a maintained community fork that is AWS SDK 2.0 and has been released to maven: https://github.com/acm19/aws-request-signing-apache-interceptor. I have a demo using that in https://github.com/dblock/opensearch-java-client-demo.

So I propose:

  1. Point to https://github.com/acm19/aws-request-signing-apache-interceptor and update the zip not to include a copy of that code.
  2. Update the doc on compression (you can enable it), and note that chunked transfer encoding currently doesn't work.

We should also (maybe later):

  1. Add an example of using pure AWS SDK v4 to communicate with OpenSearch, e.g. https://github.com/dblock/aws-sdk-sigv4-demo. Useful if you're just trying to make GET requests or send/receive JSON without additional library dependencies.
  2. Start documenting https://github.com/opensearch-project/opensearch-java which has incoming AwsSdk2Transport implementation opensearch-project/opensearch-java#177 for Sigv4 signing / a transport layer that doesn't need an interceptor.

I've also raised to the AWS SDK team the possibility of bringing the fork back under an AWS org, but we don't have to wait for it.

@arunx2 WDYT? I will push this one through into the docs in either state.

@lizsnyder
Copy link
Member

Hi @arunx2, I'm so sorry that I missed this. For some reason I wasn't receiving notifications of this change, so I didn't see it until someone pointed it out to me today. I will test this out tomorrow to make sure it works, and then merge.

@lizsnyder
Copy link
Member

@arunx2 do you have any comment on Daniel's comment above?

@arunx2
Copy link
Contributor Author

arunx2 commented Jul 14, 2022

@dblock I'll exclude the code and update the zip file. @lizsnyder You can review after the changes with the code.

@arunx2
Copy link
Contributor Author

arunx2 commented Jul 14, 2022

@dblock While I like the idea of not copying the code, I'm little skeptical to add a dependency not managed by AWS with an official documentation

io.github.acm19
aws-request-signing-apache-interceptor
2.1.1

I totally agree with your #3 and #4.

@dblock
Copy link
Contributor

dblock commented Jul 14, 2022

I think we should reference acm19.* because 1) that's an open-source package just like org.apache.http.* or org.opensearch.action.index.* which aren't managed by AWS either, 2) customers reading the documentation will not be copy-pasting eventually outdated, potentially buggy, or worse, insecure code.

Can we expand the zip in GitHub, so developer can see code changes, and replace the link to the zip to a link to GitHub? A zip is very developer unfriendly, we can't see history, etc.

@lizsnyder Do you have any objections?

@lizsnyder
Copy link
Member

I think we should reference acm19.* because 1) that's an open-source package just like org.apache.http.* or org.opensearch.action.index.* which aren't managed by AWS either, 2) customers reading the documentation will not be copy-pasting eventually outdated, potentially buggy, or worse, insecure code.

Can we expand the zip in GitHub, so developer can see code changes, and replace the link to the zip to a link to GitHub? A zip is very developer unfriendly, we can't see history, etc.

@lizsnyder Do you have any objections?

Sure, all of that sounds great to me

@arunx2
Copy link
Contributor Author

arunx2 commented Jul 18, 2022

@dblock I totally agree with samples in a GitHub repository than the zip file. Do we have GitHub for this sample?

@lizsnyder I've a hesitation to refer this acm19* in official documentation and in my opinion, org.apache.* and org.opensearch.* is backed by a large community and vetted process to get some changes into them. I'm not very familiar with this acm19.* package and not sure if this should be referred in AWS documentation. What's your take?

@dblock
Copy link
Contributor

dblock commented Jul 18, 2022

@dblock I totally agree with samples in a GitHub repository than the zip file. Do we have GitHub for this sample?

Can we just use this repo? sample_code/java/amazon-opensearch-docs-sample-client/...? Just not as a zip.

@lizsnyder I've a hesitation to refer this acm19* in official documentation and in my opinion, org.apache.* and org.opensearch.* is backed by a large community and vetted process to get some changes into them. I'm not very familiar with this acm19.* package and not sure if this should be referred in AWS documentation. What's your take?

Note that maven artifacts can't be removed from maven central.

And FWIW, I am a co-maintainer on the acm19 project along with @acm19 who doesn't work for Amazon (I do). If it were to disappear I'd fork it back into opensearch-project at a minimum. The alternative is to copy-paste (aka fork) code. I definitely don't support that, we want users to get bug fixes.

@lizsnyder
Copy link
Member

Unfortunately I have to agree with @arunx2. It's not an official AWS library, so recommending it would be tough. Looking at this a little more, I think it's best to wait for the AWS SDK team to bring the fork back under an AWS org. Thoughts? Can we expedite that somehow?

@dblock
Copy link
Contributor

dblock commented Jul 20, 2022

I don't think we should expect to anything to happen with the AWS SDK team, nor should we wait for it to correct the product documentation that is currently obsolete or has bugs.

@arunx2 want to update this PR with whichever state you think is right based on this discussion and we'll try to see what @lizsnyder is comfortable with merging?

return RestClient.builder(HttpHost.create(host)).setHttpClientConfigCallback(hacb -> hacb.addInterceptorLast(interceptor)).build();
}
}
```

If you prefer the high\-level REST client, which offers most of the same features and simpler code, try the following sample, which also uses the [Amazon Web Services Request Signing Interceptor](https://github.com/awslabs/aws-request-signing-apache-interceptor):
If you prefer the high\-level REST client, which offers most of the same features and simpler code, try the following sample, which also uses the [Amazon Web Services Request Signing Interceptor](https://github.com/awsdocs/aws-request-signing-apache-interceptor):
Copy link
Contributor

Choose a reason for hiding this comment

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

At the very least this link needs to be removed. The code in that repo is old and should not be used.

@lizsnyder
Copy link
Member

I don't think we should expect to anything to happen with the AWS SDK team, nor should we wait for it to correct the product documentation that is currently obsolete or has bugs.

@arunx2 want to update this PR with whichever state you think is right based on this discussion and we'll try to see what @lizsnyder is comfortable with merging?

Sounds good to me, thanks.

@arunx2
Copy link
Contributor Author

arunx2 commented Jul 26, 2022

Apologies for the delay. I inherited the bug fix to the sample code and referred source code instead of zip file.

Copy link
Contributor

@dblock dblock left a comment

Choose a reason for hiding this comment

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

This looks good enough to me!

I do think we should put SPDX-like copyright headers https://github.com/acm19/aws-request-signing-apache-interceptor/blob/master/src/main/java/io/github/acm19/aws/interceptor/http/AwsRequestSigningApacheInterceptor.java#L1 on all Java files here, but NBD.

@lizsnyder
Copy link
Member

You guys are awesome! Let me take a day to review/test everything and will hopefully be able to merge tomorrow.

@lizsnyder lizsnyder merged commit 8eb6ca2 into awsdocs:master Jul 27, 2022
@lizsnyder
Copy link
Member

Merged. Changes should show up in the public docs in about an hour or two.

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.

3 participants