Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xsalazar/terraform-aws-lambda-networking
🧮 Terraform template for allowing Lambda access to both private VPC resources and public internet access. This repository provides a baseline architecture for VPC, Internet Gateway, NAT Gateway, and Route Table configuration for AWS resources.
https://github.com/xsalazar/terraform-aws-lambda-networking
aws aws-lambda express lambda redis terraform
Last synced: 6 days ago
JSON representation
🧮 Terraform template for allowing Lambda access to both private VPC resources and public internet access. This repository provides a baseline architecture for VPC, Internet Gateway, NAT Gateway, and Route Table configuration for AWS resources.
- Host: GitHub
- URL: https://github.com/xsalazar/terraform-aws-lambda-networking
- Owner: xsalazar
- Created: 2020-07-29T05:20:15.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-08-20T06:23:09.000Z (3 months ago)
- Last Synced: 2024-08-20T08:32:10.876Z (3 months ago)
- Topics: aws, aws-lambda, express, lambda, redis, terraform
- Language: HCL
- Homepage:
- Size: 622 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# Terraform/AWS Lambda Networking Boilerplate
This project is aimed at outlining a small AWS project in which a simple NodeJS application is deployed to a Lambda function.
An API Gateway will forward requests to the Lambda, which will then do a sanity check that it can access a Redis database in the private subnet. Additionally, it will check that it can initiate an HTTP request out to the public internet to verify the networking is correctly configured.## Getting Started
### Updating Application Code
The application code that is deployed to Lambda lives in the [./app](./app) directory in the `index.js` file. Currently, this code does two checks:
- Test whether connections over the private AWS subnet are successful to talk to the Redis database
- Test whether public HTTP requests on the public internet can be initiated from the Lambda successfullyThis repository is configured to use [VSCode's devcontainer support](https://code.visualstudio.com/docs/remote/containers) to allow for local, containerized testing a development. Once VSCode has started the container, exectute the following commands on the container CLI to start Redis:
```bash
apt-get update
apt-get install redis
redis-server
```In VSCode, you can now press `F5` to launch the application or run `cd app && npm start` from a separate CLI window.
### Updating Infrastructure
The infrastructure that manages the AWS Cloud Resources lives in the [./terraform](./terraform) directory. This infrastructure can be deployed in the Actions tab of the repository. If it is the first time the infrastructure is being provisioned, a dummy Hello World application will be deployed to AWS as a placeholder.
All subsequent infrastructure changes can be deployed in the same way.
## CI/CD
This repository has two main ways to facilitate CI/CD built-in to GitHub-native workflows:
- Deploy Application: this workflow will package up the application code into a `.zip` file and deploy it to the running Lambda function via the AWS CLI
- Deploy Infrastructure: this workflow will utilize Terraform to apply the latest version of the infrastructure to the AWS Cloud## Architecture
![](assets/architecture.svg)