GithubHelp home page GithubHelp logo

devops-home-task's Introduction

AWS Lambda Deployment Guide for Interns

Welcome to your deployment task! This guide will walk you through the process of deploying AWS Lambda functions using Docker images with Terraform on LocalStack, and how to connect them to an API Gateway.

Objective

Your mission is to:

  1. Deploy a Lambda function using the jonathanpick/first-lambda:v1 Docker image. Connect it to an API Gateway, invoke the function at its root path ("/"), note down the hint provided in the response.
  2. Deploy a second Lambda function using the jonathanpick/second-lambda:v1 Docker image. This time, connect it to the same API Gateway, invoke the function at its root path ("/"), and capture the secret provided in the response.

Prerequisites

Ensure you have the following tools installed and configured:

  • Docker & Docker Compose
  • Terraform
  • AWS CLI, configured to interact with LocalStack for local deployment

Steps to Success

Step 1: Setting Up LocalStack

LocalStack mimics AWS cloud services locally, allowing you to test cloud applications without incurring costs. Use Docker Compose to spin up a LocalStack instance:

docker-compose.yml

version: '3.8'
services:
  localstack:
    image: localstack/localstack
    ports:
      - "4566:4566"
    environment:
      SERVICES: lambda,apigateway,iam,logs
      DEBUG: 1
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"

Run docker-compose up to start LocalStack.

Step 2: Terraform Configuration for Lambda Deployment

Create Terraform configurations to deploy your Lambda functions and set up the API Gateway. You'll need to modify the provider settings to point to LocalStack. Deploying first-lambda with Terraform

Define your Lambda function in Terraform using the aws_lambda_function resource. Instead of specifying a ZIP file for the code, you'll use the image_uri attribute to point to the Docker image.

Example Terraform snippet:

resource "aws_lambda_function" "first_lambda" {
  function_name = "firstLambdaFunction"
  package_type  = "Image"
  image_uri     = "jonathanpick/first-lambda:v1"
  role          = aws_iam_role.lambda_role.arn
}

Repeat the process for second-lambda.

Step 3: API Gateway Configuration

Set up an API Gateway to trigger your Lambda functions. Use Terraform to define the API Gateway and connect it to your deployed Lambda functions.

Step 4: Invoking Your Lambda Functions

After deployment, use the AWS CLI or any HTTP client to invoke your Lambda functions through the API Gateway. The invoke URL can be obtained from the Terraform output.

Bonus Challenge

Create a Docker Compose file to automate:

Spinning up LocalStack.
Running a container to deploy your Terraform configurations.
A script to invoke your Lambda functions and display the secret.

Submission

Submit your completed project via a pull request to the designated repository, or as a ZIP file through the preferred channel. Support

If you encounter any issues or have questions, feel free to reach out for assistance.

Good luck, and we're excited to see your solutions!

devops-home-task's People

Contributors

jonipick avatar avnertzur avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.