Skip to content

StefanBS/terraform-api-gateway-lambda-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello world HTTP APP using Lambda + API Gateway

Requirements

We would like you to deploy a simple "hello world" http app in AWS, using Api Gateway and Lambda.
Now it is up to you to write the code!
For the infrastructure code, use terraform.
For the application code, you can use choose which language to use.
The challenge is to write the code.
If you have an AWS account you can also deploy it, but this is not required!
Extra points: Add CI/CD to your deployment.

Solution

This solution implements a simple HTTP API in API Gateway and a zip code deployed Lambda. We use GitHub actions for CI/CD.

How to test

After deploying the terraform code:

$ curl -X POST <invoke_url>
{"message": "hello world"}
$ curl -X POST <invoke_url> -H 'content-type: application/json' -d '{ "greeter": "Stefan" }'
{"message": "hello Stefan"}

Requirements

  • For CI/CD integration to work you need to setup OIDC integration and create a role called github-action with the Trust relationship described in the link and enough permissions policies to deploy lambdas, API Gateways and CloudWatch log groups
  • Create a AWS_ACCOUNT_ID variable in your workspace with your AWS Account ID

Design notes

  • Terraform is used for initial code deployment but it's NOT used for code management. For subsequent Terraform runs changes to code are ignored.
  • A GitHub actions workflow is triggered every time there's a commit to main with changes to ./src directory

Improvements

  • Setup WAF
  • Automate Terraform pull requests with a tool like Atlantis
  • Setup a security scanner like Trivy for both Python and Terraform to run on pull requests
  • A blue/green or canary deployment strategy using Lambda aliases or another strategy

About

Deploys a Lambda behind an API Gateway

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages