Skip to content

NodeJS Serverless Image Processing function with AWS Lambda and Terraform

Notifications You must be signed in to change notification settings

ilahyani/serverless_image_converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless Image Processing with AWS Lambda and Terraform

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.

Table of Contents

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/your-repo.git
    cd your-repo
  2. 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
  3. Run Vagrant to provision the infrastructure:

    vagrant up

    This will execute the init.sh script to install necessary tools and set up the infrastructure.

Key Files and Directories

  • 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.

Configuration

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.

Example Variables

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"

About

NodeJS Serverless Image Processing function with AWS Lambda and Terraform

Resources

Stars

Watchers

Forks