Creating the API endpoint for suggestions

You may think that to expose search results, we would need another Lambda function. On the other hand, in our API endpoint, we just need the document we saved to CloudSearch, and we can directly expose it to the client. Then, we can use the similar method we used for the S3 upload and use API Gateway as a proxy between CloudSearch's AWS API and our publicly facing API.

To create such an API, let's first create a resource in the /search path using the method we already know from the earlier steps. Let's add this block to the Resources block in our CloudFormation template:

 "SearchResource": { "Type": "AWS::ApiGateway::Resource", "Properties": { "PathPart": "search", "RestApiId": { "Ref": "RestApi" ...

Get Building Serverless Architectures now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.