{"id":23257325,"url":"https://github.com/turiphro/aws-serverless-functions-and-serverless-containers","last_synced_at":"2026-05-16T11:31:07.701Z","repository":{"id":91914721,"uuid":"231268794","full_name":"turiphro/aws-serverless-functions-and-serverless-containers","owner":"turiphro","description":"A template and demo app for deploying to both AWS Lambda (Serverless Functions) and AWS Fargate (Serverless Containers)","archived":false,"fork":false,"pushed_at":"2020-02-14T09:10:23.000Z","size":172,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-10T12:13:06.293Z","etag":null,"topics":["aws","aws-fargate","aws-lambda","cloudformation","containers","docker","fargate","functions","lambda","serverless","serverless-applications","serverless-containers","serverless-examples","serverless-functions"],"latest_commit_sha":null,"homepage":"https://turiphro.nl/writings/template-serverless-functions-and-serverless-conta/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/turiphro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-01T22:03:25.000Z","updated_at":"2022-07-18T07:01:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"c75352a4-b258-42f0-9b67-0c9f74905edd","html_url":"https://github.com/turiphro/aws-serverless-functions-and-serverless-containers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/turiphro/aws-serverless-functions-and-serverless-containers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turiphro%2Faws-serverless-functions-and-serverless-containers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turiphro%2Faws-serverless-functions-and-serverless-containers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turiphro%2Faws-serverless-functions-and-serverless-containers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turiphro%2Faws-serverless-functions-and-serverless-containers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/turiphro","download_url":"https://codeload.github.com/turiphro/aws-serverless-functions-and-serverless-containers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/turiphro%2Faws-serverless-functions-and-serverless-containers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33100793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-fargate","aws-lambda","cloudformation","containers","docker","fargate","functions","lambda","serverless","serverless-applications","serverless-containers","serverless-examples","serverless-functions"],"created_at":"2024-12-19T12:28:32.744Z","updated_at":"2026-05-16T11:31:07.677Z","avatar_url":"https://github.com/turiphro.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"This repository contains the same example application twice:\n\n1. **Serverless functions**: [AWS Lambda functions](https://aws.amazon.com/lambda/) with an [API Gateway](https://aws.amazon.com/api-gateway/)\n2. **Serverless containers**: [AWS Fargate](https://aws.amazon.com/fargate/) (ECS) containers with a [load balancer](https://aws.amazon.com/elasticloadbalancing/)\n\nThe examples are meant to make it easy to compare both alternatives.\n\nA common demo UI is provided (`html/index.html`) that allows switching between the two backends. Both versions use the same storage (a `DynamoDB` table) and share the same code (`src/common.py`). Wrappers are provided to handle the API Gateway events (Functions approach) or serve a simple Flask-based REST endpoint (Container approach). Deploying the stack will update the URLs in the demo UI (`src/urls.js`), which can be opend locally, or potentially be deployed to S3/CloudFront or elsewhere.\n\n![demo-ui-screenshot](img/serverless-ui-screenshot.png)\n\nThe full stack is defined in an [AWS CloudFormation](https://aws.amazon.com/cloudformation/) template (`template.yaml`), backed by [AWS SAM](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html). Deployment includes a few additional steps, so a deployment script has been provided (`deploy.sh`).\n\n![aws-stack-infrastructure](img/serverless-functions-and-containers-infrastructure.png)\n\nNote that this repo is meant as a demo, and **the stack only includes the absolute minimum necessary to create a working app**. This demo is not meant to be used as template for production-ready applications. The CloudFormation template includes some hints about missing resources and security good practices.\n\nIt's interesting to look at the differences between both stacks:\n- **containers need plenty of components**: even if both approaches are \"serverless\" in the sense that we don't have to manage EC2 instances, the Container approach still needs an awful large amount of components to get started. The Lambda/API Gateway approach, in contrast, already comes with load balancing, concurrency, auto-scaling, and a VPC built-in. The `AWS SAM` framework comes with some handy 'meta' serverless resources; it might be time to create similar shortcuts for containers (`AWS::Serverless::Container`)?\n- **Endpoint configuration**: the Lambda variant configures the REST endpoints inside the CloudFormation template (and hence the endpoints scale independently), while the container variant has them all served together configured in code (although multiple containers \u0026 scaling policies could be made if necessary). The **payloads** are also slightly different due to the API Gateway proxy event vs the Flask (or another) framework.\n\n## Prerequisites\n- Install the [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) (if you didn't already)\n- Install the [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (if you didn't already)\n- Install [Docker](https://docs.docker.com/install/) (if you didn't already)\n\n\n## Deploy\n```\nexport DOCKER_IMAGE=${your-dockerhub-username}/serverless-blog\n\n./deploy.sh\n\n# now open or refresh html/index.html\n```\n\n\n## Test locally\nNote that actual HTTP calls require an existing DynamoDB table.\n\n```\nsam build\n\n# 1) test locally, behind full API\n# note: can keep the API running, but run 'sam build' after changes\nsam local start-api\nhttp GET http://127.0.0.1:3000/blog/\n# or perform a raw function call (without API)\nsam local invoke GetBlog --event \u003c(echo '{\"id\": \"foo\"}') | jq .\n\n# 2) test locally, Docker container\nexport TABLE_NAME=$SOME_DYNAMODB_TABLE\ndocker build -t blog .\ndocker run -it -p 5000:80 -v $PWD/src:/app -v ~/.aws:/root/.aws -e TABLE_NAME blog\n# note: can keep the container running; the code will auto-reload\nhttp GET http://127.0.0.1:5000/blog/\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturiphro%2Faws-serverless-functions-and-serverless-containers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fturiphro%2Faws-serverless-functions-and-serverless-containers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fturiphro%2Faws-serverless-functions-and-serverless-containers/lists"}