{"id":15493839,"url":"https://github.com/seriousme/docker-voting-app-aws","last_synced_at":"2026-01-24T20:19:44.403Z","repository":{"id":151653711,"uuid":"126234436","full_name":"seriousme/docker-voting-app-aws","owner":"seriousme","description":"Docker Voting App done Serverless Style using AWS","archived":false,"fork":false,"pushed_at":"2024-01-27T17:35:58.000Z","size":277,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-17T13:09:38.545Z","etag":null,"topics":["api-gateway","aws-dynamodb","serverless"],"latest_commit_sha":null,"homepage":"","language":null,"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/seriousme.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":"2018-03-21T20:07:51.000Z","updated_at":"2024-02-06T15:20:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"85a694dc-8e31-4d39-9284-6cbc5f658248","html_url":"https://github.com/seriousme/docker-voting-app-aws","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":0.08333333333333337,"last_synced_commit":"0077e1247dcd5f9c30309f495a32adaa47c66604"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/seriousme/docker-voting-app-aws","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seriousme%2Fdocker-voting-app-aws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seriousme%2Fdocker-voting-app-aws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seriousme%2Fdocker-voting-app-aws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seriousme%2Fdocker-voting-app-aws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seriousme","download_url":"https://codeload.github.com/seriousme/docker-voting-app-aws/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seriousme%2Fdocker-voting-app-aws/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28736504,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T19:23:36.361Z","status":"ssl_error","status_checked_at":"2026-01-24T19:23:28.966Z","response_time":89,"last_error":"SSL_read: 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":["api-gateway","aws-dynamodb","serverless"],"created_at":"2024-10-02T08:09:39.006Z","updated_at":"2026-01-24T20:19:44.383Z","avatar_url":"https://github.com/seriousme.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker Voting App done Serverless Style\n\n[![launch button](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=ServerlessVotingApp\u0026templateURL=https://cf-templates-dxlmf2isjd8s-eu-west-1.s3-eu-west-1.amazonaws.com/2019255sNG-voteApp-CF-template.json)\n\n## Introduction\n\nI was reading [Deploy the Voting App to AWS ECS with Fargate] by Tony Pujals\nwhere he describes how to run the [Docker Voting app demo] on AWS using [AWS\nFargate]\n\n[deploy the voting app to aws ecs with fargate]: https://medium.com/@tonypujals/deploy-the-voting-app-to-aws-ecs-with-fargate-\n[docker voting app demo]: https://github.com/subfuzion/docker-voting-app-nodejs\n[aws fargate]: https://aws.amazon.com/fargate/\n\nOf course I understand that the Docker Voting app is a showcase of Docker\ntechnology and that it's not the most exciting application from a business\nperspective. I also understand that people want to show how you can take Docker\ntechnology to AWS. However in my mind I started wondering: if I would take this\nto AWS would I be following the same path ? Or would I go Serverless ?\n\nGiven the title: I went Serverless!\n\nThe voting application is recreated using AWS ApiGateway and AWS DynamoDB only.\nThe queue service could be implemented using SNS, however one typically uses a\nqueue to ensure scalability of the database or to allow for maintenance. Both\nare handled by AWS DynamoDB automatically.\n\n![composer diagram](application-composer-voteApp-CF-template.json.png)\n\n## Creating the schema\n\nLooking at the sources of the voting app there are two endpoints:\n\n* POST /vote where you can post a vote by posting JSON like `{\"vote\":\"a\"}` or\n  `{\"vote\":\"b\"}`\n* GET /results which will give you results like:\n\n```json\n{\n  \"success\": true,\n  \"result\": {\n    \"a\": 0,\n    \"b\": 0\n  }\n}\n```\n\nCreating a JSON schema produces the following for /vote\n\n```json\n{\n  \"Vote\": {\n    \"type\": \"object\",\n    \"required\": [\"vote\"],\n    \"properties\": {\n      \"vote\": {\n        \"type\": \"string\",\n        \"enum\": [\"a\", \"b\"]\n      }\n    },\n    \"title\": \"Vote Schema\"\n  }\n}\n```\n\nand for /results\n\n```json\n{\n  \"type\": \"object\",\n  \"properties\": {\n    \"success\": {\n      \"type\": \"boolean\"\n    },\n    \"result\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"a\": {\n          \"type\": \"integer\"\n        },\n        \"b\": {\n          \"type\": \"integer\"\n        }\n      }\n    }\n  },\n  \"title\": \"Results schema\"\n}\n```\n\nLoading these in APIgateway ensures for /vote that only valid POST requests are\naccepted.\n\n## DynamoDB\n\nThe DynamoDB instance with partion key `topic` only holds one record with\n`topic` value `default` and a numeric value for `a` and `b`\n\n## APIgateway integration\n\nA succesful POST operation must result in a increment of the counter for the\nsubject of the vote in the database. This is achieved by adding the following\nintegration request mapping template to the POST operation:\n\n```json\n{\n  \"TableName\": \"VoteAppDynamoDBTable\",\n  \"Key\": {\n    \"topic\": {\n      \"S\": \"default\"\n    }\n  },\n  \"UpdateExpression\": \"ADD $input.path('$.vote') :inc\",\n  \"ExpressionAttributeValues\": {\n    \":inc\": {\n      \"N\": \"1\"\n    }\n  }\n}\n```\n\nThis, together with the rest of the integration configuration, will transform\nthe POST operation into a call to DynamoDB to increment the number of votes for\nthe subject provided.\n\nThen when pulling results the GET operation needs to be transformed into a query\non DynamoDB using an integration request mapping template\n\n```json\n{\n  \"TableName\": \"VoteAppDynamoDBTable\",\n  \"KeyConditionExpression\": \"topic = :v1\",\n  \"ExpressionAttributeValues\": {\n    \":v1\": {\n      \"S\": \"default\"\n    }\n  }\n}\n```\n\nand the response needs to be mapped to the schema listed above using an\nintegration response mapping template\n\n```\n#set($inputRoot = $input.path('$'))\n{\n  \"success\" : true,\n  \"result\" : {\n#if($inputRoot.Count==0)\n    \"a\" : 0,\n    \"b\" : 0\n#{else}\n    \"a\" : #if($inputRoot.Items[0].a==\"\")0#{else}$inputRoot.Items[0].a.N#end,\n    \"b\" : #if($inputRoot.Items[0].b==\"\")0#{else}$inputRoot.Items[0].b.N#end\n#end\n     }\n}\n```\n\nAs long as no votes have been casted it could be that the whole record does not\nexist yet or that `a` or `b` is still non-existent. This template takes care of\nthese edge cases.\n\nThe full AWS Cloudformation template can be found [here]. There is also a\n[version using Google Firebase].\n\n[here]: voteApp-CF-template.\n[version using google firebase]: https://github.com/seriousme/docker-voting-app-gcp\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseriousme%2Fdocker-voting-app-aws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseriousme%2Fdocker-voting-app-aws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseriousme%2Fdocker-voting-app-aws/lists"}