Configuring API Gateway

Finally, we need to trigger the function with API Gateway:

  1. Create a movies resource on the REST API and expose a GET method on it. If the incoming requests match the resource defined, it will call the Lambda function defined earlier:
resource "aws_api_gateway_rest_api" "api" {  name = "MoviesAPI"}resource "aws_api_gateway_resource" "proxy" {  rest_api_id = "${aws_api_gateway_rest_api.api.id}"  parent_id = "${aws_api_gateway_rest_api.api.root_resource_id}"  path_part = "movies"}resource "aws_api_gateway_method" "proxy" {  rest_api_id = "${aws_api_gateway_rest_api.api.id}"  resource_id = "${aws_api_gateway_resource.proxy.id}"  http_method = "GET"  authorization = "NONE"}resource "aws_api_gateway_integration" "lambda" { rest_api_id ...

Get Hands-On Serverless Applications with Go 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.