
Overview
I had the opportunity to create a REST API using OpenAPI and AWS CDK, so this is a memo. The following article was very helpful.

The project created this time is published in the following repository.
Connecting to OpenSearch
The implementation is done in the following Lambda.
Environment variables need to be passed to the Lambda, and the following was written in the ts file under lib.
...
const searchFn = new NodejsFunction(this, "search", {
entry: path.join(__dirname, "../lambda/search.ts"),
runtime: Runtime.NODEJS_18_X,
handler: "handler",
environment: {
ELASTIC_HOST: process.env.ELASTIC_HOST || "",
ELASTIC_USERNAME: process.env.ELASTIC_USERNAME || "",
ELASTIC_PASSWORD: process.env.ELASTIC_PASSWORD || "",
ELASTIC_INDEX_NAME: process.env.ELASTIC_INDEX_NAME || "",
},
});
...
Custom Domain
Please refer to the following file. There may be some errors, but I also tried setting up a custom domain registration and configuring it for API Gateway.
Summary
While this is a somewhat incomplete repository, we hope there are parts that may be helpful.



Comments
…