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.

https://zenn.dev/taroman_zenn/articles/91879cec40627c

The project created this time is published in the following repository.

https://github.com/nakamura196/CdkOpenapi

Connecting to OpenSearch

The implementation is done in the following Lambda.

https://github.com/nakamura196/CdkOpenapi/blob/main/lambda/search.ts

Environment variables need to be passed to the Lambda, and the following was written in the ts file under lib.

const})serhe};enuan,atnnvEEEErrtdiLLLLcyilrAAAAh:meoSSSSFernTTTTnp::mIIIIaeCCCC=tR"n____huhtHUPIn.na:OSANejtnSESDwoid{TRSEiml:NWXNneeAO_o(.rpMRNd_N"rEDAe_O,o::MjdDcEsiEepp:FrJsrrunSsoopna_.ccrcm1eeeote8nssci,_vsseoX...sn",Eees(.Lnn.t.Avveh/S..nilTEEvsaILL.,mCAAEb_SSL"dHTTAsaOIISe/SCCTasT__IreUPCcaSA_hrESI"cRSN,h"NWD."AOE{t,MRXsED_"N)A,ME"""",,"",

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.

https://github.com/nakamura196/CdkOpenapi/blob/main/lib/cdk-openapi-stack.ts

Summary

While this is a somewhat incomplete repository, we hope there are parts that may be helpful.