{"id":34199785,"url":"https://github.com/merlincox/aws-api-gateway-deploy","last_synced_at":"2026-03-10T20:04:54.350Z","repository":{"id":53135550,"uuid":"163764217","full_name":"merlincox/aws-api-gateway-deploy","owner":"merlincox","description":"Deploy an AWS API gateway with sample Golang handler","archived":false,"fork":false,"pushed_at":"2021-04-05T10:47:37.000Z","size":32,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-09T21:39:06.087Z","etag":null,"topics":["api-gateway","aws","lambda","swagger"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/merlincox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-01T20:26:00.000Z","updated_at":"2021-04-05T10:43:29.000Z","dependencies_parsed_at":"2022-09-16T02:40:29.622Z","dependency_job_id":null,"html_url":"https://github.com/merlincox/aws-api-gateway-deploy","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/merlincox/aws-api-gateway-deploy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merlincox%2Faws-api-gateway-deploy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merlincox%2Faws-api-gateway-deploy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merlincox%2Faws-api-gateway-deploy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merlincox%2Faws-api-gateway-deploy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/merlincox","download_url":"https://codeload.github.com/merlincox/aws-api-gateway-deploy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merlincox%2Faws-api-gateway-deploy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30351885,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T15:55:29.454Z","status":"ssl_error","status_checked_at":"2026-03-10T15:54:58.440Z","response_time":106,"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":["api-gateway","aws","lambda","swagger"],"created_at":"2025-12-15T18:04:26.759Z","updated_at":"2026-03-10T20:04:54.341Z","avatar_url":"https://github.com/merlincox.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## aws-api-gateway-deploy\n\nThis repo contains a Bash deploy script and a CloudFormation template for deploying a serverless API implemented as a\n AWS API Gateway served by a simple Golang lambbda\n\nThe template\n\n* Creates the lambda and passes an environment to it\n* Creates the API Gateway with two sample endpoints linked to the lambda\n* Creates a subdomain mapped to the API\n\nAltogether, the deployment script enables you to create to `https://{your-sub-domain}.{your-domain}/status` endpoint,\n an example environment for the API (in the supplied example git tag, branch, and commit information and a \n'platform' variable). Redirection of HTTP to HTTPS and CloudWatch logging are automatically supplied by the gateway.\n\n### Prerequsisites\n\n* A domain with a hosted-zone record in AWS Route 53\n* A single, valid and up-to-date SSL certificate for that domain in the AWS Certificate Manager. Note that this certificate must be in the \n`us-east-1` AWS region because it is deployed to CloudFront.\n* The AWS command line interface `aws` installed and suitably set up with credentials for your AWS account\n* `go` installed to a version supporting Go modules\n* `git` installed\n* `jq` installed (`jq` is a very useful command-line tool for manipulating JSON. See https://stedolan.github.io/jq.)\n\n### Deployment\n\nThe deployment script usage is:\n \n `./deploy.sh subdomain_base domain [platform]`\n\n`platform` is intended to be 'test', 'stage' or 'test' ('test' is the default)\n\n'-test' and '-stage' are appended to the `subdomain_base`\n\nExamples: \n\n`./deploy.sh my-api my-domain.com` will deploy an API at `https://my-api-test.my-domain.com`\n\n`./deploy.sh my-api my-domain.com stage` will deploy an API at `https://my-api-stage.my-domain.com`\n\n`./deploy.sh my-api my-domain.com live` will deploy an API at `https://my-api.my-domain.com`\n\nUncommited code cannot be deployed, and live deploys have these additional checks:\n\n* code must be on the master branch\n* code must be sync with the remote origin\n* code must be exactly on a tag of the form \n\nLastly, deploys to the live platform will present a confirmation prompt.\n\nNote that the first time a stack is created there will be a significant delay before the subdomain is available due to \npropagation but subsequent updates should be quite fast.\n\n### Exporting Swagger JSON and models\n\nThe API definition YAML includes a Swagger definition for the API.\n\nThis can be exported using the `export.sh` script.\n\nIn addition a schema-generator executable can be created from here: https://github.com/merlincox/generate\n\nIf this is added to the system path, the `export.sh` will also generate Go structs for the API and optionally replace \nthe pkg/models/api.go file if that is out of sync with the API. (Therefore any additionmal models which do not feature \ndirectly in the API should be placed in the pkg/models/models.go file).\n\n### Endpoints\n\nThe `/status` endpoint demonstrates that the environment has been passed to the lambda, and will return the git branch\ncommit and release tag, the platform and a timestamp for when the lambda was first invoked.\n\nThe `/calc` endpoint uses simple maths functions to demonstrate handling of path and query parameters, headers, error-handling and API-level caching.\n\nUsage:\n\n`https://{my-subdomain}[-{platform}].{my-domain}/calc/{op}?val1={val1}\u0026val2={val2}`\n\nwhere {op} can be one of \"add\", \"substract\", \"multiply\", \"divide\", \"power\" or \"root\" (all of which can be shortened to \n3 letters) and val1 and va12 are numbers.\n\nThe Accept-Language request header can optionally be used to format the result.\n\nFor example, `/calc/mul?val1=423.456\u0026val2=30.1` with Accept-Language set to \"en-GB\" will return\n\n```\n{\n     \"locale\": \"en-GB\",\n     \"op\": \"multiply\",\n     \"result\": \"12,746.0256\",\n     \"val1\": 423.456,\n     \"val2\": 30.1\n}\n```\nwhereas with Accept-Language as \"fr-FR\" it will produce\n```\n{\n     \"locale\": \"fr-FR\",\n     \"op\": \"multiply\",\n     \"result\": \"12 746,0256\",\n     \"val1\": 423.456,\n     \"val2\": 30.1\n}\n```\n\nAPI-level caching can determined by looking at the x-Timestamp response header. If you repeat a query and the value of \nthis header does not change, you are seeing a cached response.\n\n\nThis endpoint also demonstrates error handling.\n\n`/calc/div?val1=423.456\u0026val2=0` will return\n\n```\n{\n    \"message\": \"Out of limits: 423.456 divide 0\",\n    \"code\": 400\n}\n\n```\n\n`calc/bad?val1=423.456\u0026val2=123` will return\n\n```\n{\n    \"message\": \"Unknown calc operation: bad\",\n    \"code\": 400\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerlincox%2Faws-api-gateway-deploy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmerlincox%2Faws-api-gateway-deploy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerlincox%2Faws-api-gateway-deploy/lists"}