Turn your lambdas into HTTP services with API Gateway.This is the 3rd article in my ‘Golang Fantasy Hunting App’ series. It’s recommended that you start with the first post, here. At the end of the previous article, we had managed to develop a working integration between our save-and-update lambda and dynamo. The last step is using AWS API Gateway to proxy HTTP requests through to the lambda, so that we can use it as a web service.
This is the 3rd article in my ‘Golang Fantasy Hunting App’ series. It’s recommended that you start with the first post, here.
At the end of the previous article, we had managed to develop a working integration between our save-and-update lambda and dynamo. The last step is using AWS API Gateway to proxy HTTP requests through to the lambda, so that we can use it as a web service.
We need to do five things for this to work:
Create a new API
An HTTP API is like a set of rules which describe how users can interact with your backend. An API is associated with a base URL, e.g.
www.example.com and then one or more
paths which denote different domains, processes, areas etc. that your API has. For example,
www.example.com/users might return a list of users that belong to
www.example.com/user/create might be used to access the bit of backend functionality that creates a new user. By hitting any of these URLs in your browser and providing whatever data might be needed, you can fire off the backend operation that does whatever it is you want to be done. Our API will do one thing, for now, and that is
save a monster record. In our case,
save means create or update, depending on whether the provided ID is already defined in our database. We will have one
/monsters and it will receive a JSON payload containing the monster object we want to save.
Head to the AWS API Gateway console. You’ll see something like the following.
Hit ‘Create API’ to get started. On the next page, click ‘build’ under ‘REST API’; not the one that only works from within a VPC.
Fill in the name, ignore everything else, and click ‘Create API’.
Create the endpoint and proxy requests
You should see a page like the following
APIs, short for Application Programming Interfaces, are connection points that allow different (parts of) computer programs to exchange data. Using APIs for the delivery of a software service makes your code better organized and easily reusable. In this article, I am going through the basic steps of creating an API using AWS Lambda and API Gateway.
In this article, we explain general API implementation concepts using AWS Lambda and other AWS services. APIs are a crucial part of any web application and there are different techniques for development and design. Serverless is one approach gaining popularity, because of its cost-efficiency, scalability and relative simplicity. As a leading serverless provider, Amazon Web Services (AWS) has made a huge contribution to the world of serverless development, and in this article, we will explain general API implementation concepts using AWS Lambda and other AWS services.
Serverless Express enables you to easily host Express.js APIs on AWS Lambda and AWS HTTP API. Here is how to get started and deliver a Serverless Express.js based API with a custom domain, free SSL certificate and much more!
This article shows how to program an API to return status codes that make sense to your application.
This tutorial will show you how to resolve a very frustrating CORS issue with AWS Lambda and API Gateway from a browser.