Skip to content

Commit f0ace05

Browse files
dblockacm19
authored andcommitted
Added support for OpenSearch Serverless.
Signed-off-by: dblock <dblock@amazon.com>
1 parent 12cee0f commit f0ace05

18 files changed

+70
-45
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
### 2.2.1 (Next)
1+
### 2.3.0 (Next)
22

3+
* [#94](https://github.com/acm19/aws-request-signing-apache-interceptor/pull/94): Add support for OpenSearch Serverless - [@dblock](https://github.com/dblock).
34
* [#92](https://github.com/acm19/aws-request-signing-apache-interceptor/pull/92): Make samples compatible with OpenSearch 2.x - [@dblock](https://github.com/dblock).
45

56
### 2.2.0 (2022/10/02)

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
REGION?=us-east-1
22
ENDPOINT?=http://my-domain.us-east-1.opensearch.localhost.localstack.cloud:4566
3+
SERVICE?=es
34

45
.PHONY: verify
56
.SILENT: verify
@@ -12,21 +13,21 @@ run_sample:
1213
mvn test-compile exec:java \
1314
-Dexec.classpathScope=test \
1415
-Dexec.mainClass="io.github.acm19.aws.interceptor.test.AmazonOpenSearchServiceSample" \
15-
-Dexec.args="--endpoint=$(ENDPOINT) --region=$(REGION)"
16+
-Dexec.args="--endpoint=$(ENDPOINT) --region=$(REGION) --service=$(SERVICE)"
1617

1718
.PHONY: run_v5_sample
1819
.SILENT: run_v5_sample
1920
run_v5_sample:
2021
mvn test-compile exec:java \
2122
-Dexec.classpathScope=test \
2223
-Dexec.mainClass="io.github.acm19.aws.interceptorv5.test.AmazonOpenSearchServiceSample" \
23-
-Dexec.args="--endpoint=$(ENDPOINT) --region=$(REGION)"
24+
-Dexec.args="--endpoint=$(ENDPOINT) --region=$(REGION) --service=$(SERVICE)"
2425

2526
debug_v5_sample:
2627
mvn exec:exec -Dexec.executable="java" -Dexec.classpathScope=test \
2728
-Dexec.args="-classpath %classpath -Xdebug \
2829
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 \
29-
io.github.acm19.aws.interceptorv5.test.AmazonOpenSearchServiceSample --endpoint=$(ENDPOINT) --region=$(REGION)"
30+
io.github.acm19.aws.interceptorv5.test.AmazonOpenSearchServiceSample --endpoint=$(ENDPOINT) --region=$(REGION) --service=$(SERVICE)"
3031

3132
.PHONY: validate_renovate_config
3233
.SILENT: validate_renovate_config

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
An AWS request signing interceptor for arbitrary HTTP requests. It supports both [Apache HTTP Client](https://search.maven.org/artifact/org.apache.httpcomponents/httpclient) and [Apache HTTP Client V5](https://search.maven.org/artifact/org.apache.httpcomponents.client5/httpclient5).
77

8-
This library enables you to sign requests to any service that leverages SigV4, and thus access any AWS Service or APIG-backed service.
8+
This library enables you to sign requests to any service that leverages SigV4, and thus access any AWS Service or APIG-backed service, including Amazon managed OpenSearch and OpenSearch Serverless.
99

1010
This library is based on [AWS Interceptor](https://github.com/awslabs/aws-request-signing-apache-interceptor), but using AWS SDK 2.x.
1111

@@ -110,13 +110,13 @@ export AWS_ACCESS_KEY_ID=
110110
export AWS_SECRET_ACCESS_KEY=
111111
export AWS_SESSION_TOKEN=
112112
113-
mvn test-compile exec:java -Dexec.classpathScope=test -Dexec.mainClass="io.github.acm19.aws.interceptor.test.AmazonOpenSearchServiceSample" -Dexec.args="--endpoint=https://...us-west-2.es.amazonaws.com --region=us-west-2"
113+
mvn test-compile exec:java -Dexec.classpathScope=test -Dexec.mainClass="io.github.acm19.aws.interceptor.test.AmazonOpenSearchServiceSample" -Dexec.args="--endpoint=https://...us-west-2.es.amazonaws.com --region=us-west-2 --service=es"
114114
```
115115

116116
Alternatively use `make` as follows:
117117

118118
```
119-
ENDPOINT=<your-endpoint> REGION=<your-region> make run_sample
119+
ENDPOINT=<your-endpoint> SERVICE=es REGION=<your-region> SERVICE=es make run_sample
120120
```
121121

122122
See [examples](src/test/java/io/github/acm19/aws/interceptor/test) for more valid requests.
@@ -130,13 +130,13 @@ export AWS_ACCESS_KEY_ID=
130130
export AWS_SECRET_ACCESS_KEY=
131131
export AWS_SESSION_TOKEN=
132132
133-
mvn test-compile exec:java -Dexec.classpathScope=test -Dexec.mainClass="io.github.acm19.aws.interceptorv5.test.AmazonOpenSearchServiceSample" -Dexec.args="--endpoint=https://...us-west-2.es.amazonaws.com --region=us-west-2"
133+
mvn test-compile exec:java -Dexec.classpathScope=test -Dexec.mainClass="io.github.acm19.aws.interceptorv5.test.AmazonOpenSearchServiceSample" -Dexec.args="--endpoint=https://...us-west-2.aoss.amazonaws.com --region=us-west-2 --service=aoss"
134134
```
135135

136136
Alternatively use `make` as follows:
137137

138138
```
139-
ENDPOINT=<your-endpoint> REGION=<your-region> make run_v5_sample
139+
ENDPOINT=<your-endpoint> REGION=<your-region> SERVICE=aoss make run_v5_sample
140140
```
141141

142142
See [examples](src/test/java/io/github/acm19/aws/interceptorv5/test) for more valid requests.

infra/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ This project creates an OpenSearch cluster on AWS for development purposes. Its
66
To manually create a virtualenv and install the dependencies on MacOS and Linux:
77

88
```
9-
make .venv
9+
make venv
1010
```
1111

1212
After the init process completes and the virtualenv is created, you can use the following step to activate your virtualenv.
1313

1414
```
15-
source .venv/bin/activate
15+
source ./venv/bin/activate
1616
```
1717

1818
At this point you can now synthesise the CloudFormation template for this code.

infra/opensearch_cluster/opensearch_cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
1010

1111
open_search_cluster = aws_opensearchservice.Domain(self,
1212
"InterceptorTest",
13-
version=EngineVersion.OPENSEARCH_1_2,
13+
version=EngineVersion.OPENSEARCH_2_3,
1414
capacity=aws_opensearchservice.CapacityConfig(
1515
data_node_instance_type="t3.small.search"
1616
),

infra/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infra/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "aws-request-signing-apache-interceptor",
33
"version": "1.0.0",
44
"devDependencies": {
5-
"aws-cdk": "2.58.1"
5+
"aws-cdk": "2.61.1"
66
},
77
"author": "acm19"
88
}

infra/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
aws-cdk-lib==2.58.1
1+
aws-cdk-lib==2.61.1
22
constructs==10.1.206
33
types-setuptools==65.6.0.2

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>io.github.acm19</groupId>
66
<artifactId>aws-request-signing-apache-interceptor</artifactId>
7-
<version>2.2.1-SNAPSHOT</version>
7+
<version>2.3.0-SNAPSHOT</version>
88
<packaging>jar</packaging>
99

1010
<name>AWS Request Signing Apache Interceptor</name>

src/main/java/io/github/acm19/aws/interceptor/http/AwsRequestSigningApacheInterceptor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ public void process(final HttpRequest request, final HttpContext context)
9898
requestBuilder.contentStreamProvider(() -> new ByteArrayInputStream(outputStream.toByteArray()));
9999
}
100100
}
101-
requestBuilder.headers(headerArrayToMap(request.getAllHeaders()));
101+
102+
Map<String, List<String>> headers = headerArrayToMap(request.getAllHeaders());
103+
// adds a hash of the request payload when signing
104+
headers.put("x-amz-content-sha256", Collections.singletonList("required"));
105+
requestBuilder.headers(headers);
102106
SdkHttpFullRequest signedRequest = signer.signRequest(requestBuilder.build());
103107

104108
// copy everything back

0 commit comments

Comments
 (0)