Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/horothesun/api-gateway-lambda-infra
API Gateway triggered Lambda infrastructure.
https://github.com/horothesun/api-gateway-lambda-infra
aws aws-api-gateway aws-api-gateway-v2 aws-apigateway aws-apigw aws-lambda ci infra infrastructure infrastructure-as-code terraform terraform-module
Last synced: 10 days ago
JSON representation
API Gateway triggered Lambda infrastructure.
- Host: GitHub
- URL: https://github.com/horothesun/api-gateway-lambda-infra
- Owner: horothesun
- License: mit
- Created: 2022-12-21T23:40:04.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-10T22:15:14.000Z (6 months ago)
- Last Synced: 2024-05-10T23:25:01.057Z (6 months ago)
- Topics: aws, aws-api-gateway, aws-api-gateway-v2, aws-apigateway, aws-apigw, aws-lambda, ci, infra, infrastructure, infrastructure-as-code, terraform, terraform-module
- Language: HCL
- Homepage:
- Size: 39.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# API Gateway triggered Lambda infrastructure
[![CI](https://github.com/horothesun/api-gateway-lambda-infra/actions/workflows/ci.yml/badge.svg)](https://github.com/horothesun/api-gateway-lambda-infra/actions/workflows/ci.yml)
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg?style=flat-square)](https://renovatebot.com)
[![Mergify enabled](https://img.shields.io/badge/Mergify-enabled-success.svg?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAABCRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xO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
[horothesun/api-gateway-lambda-template.g8](https://github.com/horothesun/api-gateway-lambda-template.g8)
## Setup
- Add the following block to your infrastructure code
```terraform
module "demo_api_gateway_lambda" {
source = "github.com/horothesun/api-gateway-lambda-infra?ref=1.0.0"lambda_name = "demo-api-gateway-lambda"
lambda_memory_MB = 512
lambda_logs_retention_days = 7
http_method = "GET"
http_route = "/time"
http_timeout_seconds = 30
apigw_logs_retention_days = 7
burst_limit_rps = 1
rate_limit_rps = 1
initial_setup = true # TO BE REMOVED once the first ECR image gets created!
}
```- Make sure your AWS OIDC for GitHub workflows role only contains permissions referencing
`ecr_repo_arn` and NOT `lambda_function_arn`.
- Apply the Terraform changes.
- Run the service CI pipeline to publish the first ECR image
(the pipeline will fail at the "Update lambda" stage).
- Remove `initial_setup` from your configuration (defaulting it to `false`).
- Update your AWS OIDC for GitHub workflows role by adding the permission
referencing `lambda_function_arn` as well.
- Apply the Terraform changes again.
- Run the service CI pipeline again to update the lambda with the latest ECR image.