Golang Fantasy Hunting App, 3: Use your Lambda as an HTTP Backend with API Gateway

Golang Fantasy Hunting App, 3: Use your Lambda as an HTTP Backend with API Gateway

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:

  1. Create a new API through the API gateway console
  2. Create a new endpoint
  3. Proxy all requests through to our lambda
  4. Test the API
  5. Deploy the API

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 example.com. Then, 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 path/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.

Image for post

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’.

Image for post

Create the endpoint and proxy requests

You should see a page like the following

aws api-gateway golang programming lambda

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Build an API in AWS - Using AWS Lambda and API Gateway

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.

Build a Serverless API with AWS Gateway and Lambda

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 – Easy APIs On AWS Lambda & AWS HTTP API

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!

Integrating API Gateway — Lambda Responses

This article shows how to program an API to return status codes that make sense to your application.

React.js API calls to AWS Lambda, API Gateway and dealing with CORS

This tutorial will show you how to resolve a very frustrating CORS issue with AWS Lambda and API Gateway from a browser.