Git Product home page Git Product logo

example-lambda-to-ecs's Introduction

Example Run Lambda like tasks in ECS Fargate

This repo is to demo how simple it is to use ECS Fargate to replace longer running lambda functions. To read more about this process please read the corresponding blog post.

https://www.gravitywell.co.uk/insights/using-ecs-tasks-on-aws-fargate-to-replace-lambda-functions/

Setup this project

  • Find and replace all instances of ACCOUNT_ID with your AWS account ID
  • yarn install

Testing/running functions locally

For the purpose of this repository, you can test the runtime code by running the commands:

  • yarn invoke:js-example - to run the example Javascript file
  • yarn invoke:ts-example - to run the example Typescript file with esbuild

Deploying your infrastructure

The project uses AWS CDK to provision all the required infrastructure. To deploy the infrastructure run:

  • yarn cdk deploy ExampleLambdaToEcsStack

Deploy your docker code

The deployment of code is separated out so that you can deploy infrastructure and code separately. In the repo there are 2 ways to deploy you code.

To deploy the Javascript handler example run:

  • yarn deploy:docker:js

To deploy the Typescript handler example run:

  • yarn deploy:docker:ts

What isn't in this repo

There is a file name tidy-up-ecs-tasks.ts. This is an example of a lambda function that could be used to stop any ECS tasks that have been running too long, too avoid paying huge AWS costs on tasks that do not shut down correctly. This repo does not provide any infrastructure for the lambda function or the event bridge cron schedule.

This repo is intentionally over simplified to focus on the infrastructure and process. As always in a production environment I would advise using CI/CD processes to formalize the automation of building/testing/deploying infrastructure and code

example-lambda-to-ecs's People

Contributors

georgeevans1995 avatar

Stargazers

Ashish Yengkhom avatar FredericH avatar Chris Tregaskis avatar Vlad Mihai Savin avatar Máté Donka avatar  avatar Jonathan Land avatar  avatar  avatar tm1sir avatar Felipe Lisboa avatar  avatar Scott Havird 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.