Coder Social home page Coder Social logo

chrisbirster / cdk-lambda-fleet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sbstjn/cdk-lambda-fleet

0.0 1.0 0.0 98 KB

Deploy AWS Lambda functions using docker images to ECR with AWS CDK

Home Page: https://sbstjn.com/blog/aws-cdk-lambda-fleet-multiple-docker-images-container/

License: MIT License

TypeScript 60.04% JavaScript 14.12% Dockerfile 23.22% Python 2.62%

cdk-lambda-fleet's Introduction

AWS CDK: Lambda Fleet

MIT License cdk-lambda-fleet on NPM

Deploy multiple AWS Lambda functions as container images to Amazon ECR with CDK.

Examples

CDK Construct

When using the AWS CDK in TypeScript, you can use the published LambdaFleet construct:

$ > yarn install cdk-lambda-fleet
import * as path from "path";
import * as cdk from "@aws-cdk/core";

import { LambdaFleet } from "cdk-lambda-fleet";

export class FleetStack extends cdk.Stack {
  constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    new LambdaFleet(this, "Fleet", {
      path: path.resolve(__dirname, "../src"),
    });
  }
}

Configuration

You can fork this repository and create a folder like src/lambda-python-example and store a Dockerfile there:

FROM amazon/aws-lambda-python:3.8

COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY handler.py ./

CMD [ "handler.run" ]

Using the AWS CDK, a docker image will be created and deployed to Amazon ECR for every folder in src/. After uploading the image, an AWS Lambda will be created or updated to use the latest image.

Deployment

# Deploy all functions

$ > yarn deploy

[…]

Fleet.FleetLambdaNodeExampleArnXYZ = "arn:aws:lambda:eu-central-1:123:function:Fleet-FleetLambdaNodeExampleXYZ-XYZ"
Fleet.FleetLambdaPythonExampleArnXYZ = "arn:aws:lambda:eu-central-1:123:function:Fleet-FleetLambdaPythonExampleXYZ-XYZ"
Fleet.FleetLambdaTypescriptExampleArnXYZ = "arn:aws:lambda:eu-central-1:123:function:Fleet-FleetLambdaTypescriptExampleXYZ-XYZ"

cdk-lambda-fleet's People

Contributors

sbstjn avatar

Watchers

 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.