This project sets up a serverless infrastructure for image processing using AWS Lambda, Terraform, and Node.js. The infrastructure is provisioned using Vagrant and Terraform, and the Lambda function is written in Node.js.
-
Clone the repository:
git clone https://github.com/yourusername/your-repo.git cd your-repo
-
Set up environment variables:
Make sure you have the following environment variables exported in your shell with your AWS Credentials
AWS_ACCESS_KEY_ID=your_access_key_id AWS_SECRET_ACCESS_KEY=your_secret_access_key AWS_REGION=your_aws_region
-
Run Vagrant to provision the infrastructure:
vagrant up
This will execute the
init.sh
script to install necessary tools and set up the infrastructure.
init.sh
: Script to set up the environment and install necessary tools.function/
: Contains the Node.js Lambda function code.terraform/
: Contains Terraform configuration files for provisioning AWS resources..github/workflows/main.yml
: GitHub Actions workflow for deploying the infrastructure.
The configuration for the Lambda function and other resources is managed through Terraform variables. These variables are defined in terraform/modules/lambda/variables.tf
and can be set in the .github/workflows/main.yml
file or terraform/terraform.tfvars
if you're working locally.
env:
TF_VAR_lambda_function_name: "webp_convert"
TF_VAR_lambda_runtime: "nodejs18.x"
TF_VAR_lambda_handler: "index.handler"
TF_VAR_lambda_src_code: "../function"
TF_VAR_lambda_zip: "./lambda.zip"
TF_VAR_original_files_bucket_name: "bucket-orginal-file"
TF_VAR_edited_files_bucket_name: "bucket-edit-file"