Run the same Docker images in AWS Lambda and AWS ECS

Overview

serverlessish

tl;dr Run the exact same image for websites in Lambda as you do in ECS, Kubernetes, etc. Just add this to your Dockerfile, listen on port 8080 and have a health check returning 200 at /ping. This image will now work in Lambda and everywhere else and adds less than 2 MB.

Dockerfile example

Those lines for copy-paste friendliness:

FROM public.ecr.aws/c2t6n2x5/serverlessish:2 AS lh
# FROM ...
COPY --from=lh /opt/extensions/serverlessish /opt/extensions/serverlessish

# optionally add these lines
ENV PORT=9090                        # maybe you want a different port
ENV LH_HEALTHCHECK_PATH=/healthcheck # or a different healthcheck path

TODO

More documentation.

Story time: Christmas came early in 2020 with the release of container image support for AWS Lambda. It meant that serverless applications could now be packaged in standard Docker images rather than Lambda-specific ZIP files. Additionally, the 50 MB limit for ZIP files doesn't apply to containers: they can be as enormous as 10 GB.

You might also like...
Cloud cost estimates for Terraform in your CLI and pull requests πŸ’°πŸ“‰
Cloud cost estimates for Terraform in your CLI and pull requests πŸ’°πŸ“‰

Infracost shows cloud cost estimates for Terraform projects. It helps developers, devops and others to quickly see the cost breakdown and compare different options upfront.

Fleex allows you to create multiple VPS on cloud providers and use them to distribute your workload.
Fleex allows you to create multiple VPS on cloud providers and use them to distribute your workload.

Fleex allows you to create multiple VPS on cloud providers and use them to distribute your workload. Run tools like masscan, puredns, ffuf, httpx or anything you need and get results quickly!

β˜οΈπŸƒ Get up and running with Go on Google Cloud.

Get up and running with Go and gRPC on Google Cloud Platform, with this lightweight, opinionated, batteries-included service SDK.

Elkeid is a Cloud-Native Host-Based Intrusion Detection solution project to provide next-generation Threat Detection and Behavior Audition with modern architecture.
Elkeid is a Cloud-Native Host-Based Intrusion Detection solution project to provide next-generation Threat Detection and Behavior Audition with modern architecture.

Elkeid is a Cloud-Native Host-Based Intrusion Detection solution project to provide next-generation Threat Detection and Behavior Audition with modern architecture.

Sample apps and code written for Google Cloud in the Go programming language.
Sample apps and code written for Google Cloud in the Go programming language.

Google Cloud Platform Go Samples This repository holds sample code written in Go that demonstrates the Google Cloud Platform. Some samples have accomp

Use Google Cloud KMS as an io.Reader and rand.Source.

Google Cloud KMS Go io.Reader and rand.Source This package provides a struct that implements Go's io.Reader and math/rand.Source interfaces, using Goo

A Cloud Native Buildpack that contributes SDKMAN and uses it to install dependencies like the Java Virtual Machine

gcr.io/paketo-buildpacks/sdkman A Cloud Native Buildpack that contributes SDKMAN and uses it to install dependencies like the Java Virtual Machine. Be

Microshift is a research project that is exploring how OpenShift1 Kubernetes can be optimized for small form factor and edge computing.

Microshift is a research project that is exploring how OpenShift1 Kubernetes can be optimized for small form factor and edge computing.

A Cloud Foundry cli plugin that offers a faster and customizable alternative for cf apps

Panzer cf cli plugin A plugin for faster interaction (less API calls) with Cloud Foundry, and choose the columns you want in your output. Instead of "

Comments
  • Allow usage of

    Allow usage of "/" as LH_HEALTHCHECK_PATH

    Presently if you try to set LH_HEALTHCHECK_PATH to just / it will be trimmed and then compared to an empty string and reset to ping.

    This moves the comparison before the trimming to differentiate between the default empty string and /.

    opened by tma-isbx 2
  • Response headers sent twice in API Gateway response

    Response headers sent twice in API Gateway response

    I was having the following error in chrome:

    Access to fetch at 'https://***.execute-api.eu-west-1.amazonaws.com/api.php' from origin 'https://***' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values 'https://***, https://***', but only one is allowed. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
    

    after a curl -v on the execute-api endpoint, I can see the headers are indeed sent twice:

    < HTTP/2 200
    < date: Mon, 21 Dec 2020 19:14:38 GMT
    < content-type: text/html; charset=UTF-8
    < content-length: 0
    < access-control-allow-origin: https://***
    < access-control-allow-origin: https://***
    < access-control-allow-headers: Content-Type
    < access-control-allow-headers: Content-Type
    < apigw-requestid: X6sUujpVjoEEM-Q=
    

    those headers are sent by the application running behind serverlessish, but when running locally they are sent only once

    after review the code in http.go#L51, I see the headers are set once in json:"headers" and once in json:"multiValueHeaders":

    	output := &httpResponseOutput{
    		StatusCode:        resp.StatusCode,
    		StatusDescription: resp.Status,
    		HeadersMV:         resp.Header,
    		Headers:           headers,
    		Body:              encoded,
    		IsBase64Encoded:   true,
    	}
    

    According to the following article: https://aws.amazon.com/blogs/compute/support-for-multi-value-parameters-in-amazon-api-gateway/

    "You can also pass the header key along with the multiValueHeaders key. In that case, API Gateway merges the multiValueHeaders and headers maps while processing the integration response into a single Map<String, List> value. If the same key-value pair is sent in both, it isn’t duplicated."

    I wonder where the issue might come from

    opened by guillaumesmo 2
  • how does this binary get invoked?

    how does this binary get invoked?

    Hey, this project looks super interesting! I'm certain I'm missing something here, but how does the /opt/extensions/serverlessish binary get invoked/bootstrapped? It looks like once the serverlessish executable is started, it polls the lambda runtime api for events (sent by APIG/ALB) and forwards/proxies them to the user's http server process. Just not seeing how it gets bootstrapped. It looks like the Dockerfile's entrypoint is the user's executable.

    opened by jritsema 1
Releases(0.1.0)
Owner
Glass Echidna
Glass Echidna
AWS Lambda to work around index.html S3/CloudFront mess

No more index.html mess with AWS CloudFront/S3 Problem Consider you have a statically generated site β€” a bunch of usual resources, including html file

Artyom Pervukhin 26 Jun 18, 2022
Tool to generate certificate images easily.

Arthur A program to generate certificates with the same appearance but with different data. Thanks to foggleman/gg rendering 2D graphics library as ma

HMIF UNSRI 2 Jun 17, 2022
Contentrouter - Protect static content via Firebase Hosting with Cloud Run and Google Cloud Storage

contentrouter A Cloud Run service to gate static content stored in Google Cloud

G. Hussain Chinoy 0 Jan 2, 2022
AWS SDK for the Go programming language.

AWS SDK for Go aws-sdk-go is the official AWS SDK for the Go programming language. Checkout our release notes for information about the latest bug fix

Amazon Web Services 7.9k Sep 27, 2022
Generate a basic IAM policy from AWS client-side monitoring (CSM)

iamlive Generate a basic IAM policy from AWS client-side monitoring (CSM) Installation Pre-built binaries Pre-built binaries for Windows, macOS and Li

Ian Mckay 2.1k Sep 22, 2022
AWS plugin for Steampipe

Use SQL to query IAM users, EC2 instances and more from your AWS account.

Turbot 98 Sep 27, 2022
This example shows how to serve private contents on AWS S3 through CloudFront signed URL.

AWS CloudFront with Signed URL This is the repository of my blog post. This example shows how to serve private contents on AWS S3 through CloudFront s

Hao-Ming, Hsu 6 Jul 19, 2022
Experiment - Sync files to S3, fast. Go package and CLI.

gosync I want to be the fastest way to concurrently sync files and directories to/from S3. Gosync will concurrently transfer your files to and from S3

null 153 Dec 6, 2021
Production-Grade Container Scheduling and Management

Kubernetes (K8s) Kubernetes, also known as K8s, is an open source system for managing containerized applications across multiple hosts. It provides ba

Kubernetes 92.1k Sep 17, 2022
JuiceFS is a distributed POSIX file system built on top of Redis and S3.

JuiceFS is an open-source POSIX file system built on top of Redis and object storage (e.g. Amazon S3), designed and optimized for cloud native environ

Juicedata, Inc 6.7k Sep 27, 2022