{"id":24012915,"url":"https://github.com/glassechidna/codedeployhook","last_synced_at":"2026-04-29T16:39:41.674Z","repository":{"id":84300141,"uuid":"202533675","full_name":"glassechidna/codedeployhook","owner":"glassechidna","description":"Safe AWS Serverless website deployments made easy","archived":false,"fork":false,"pushed_at":"2023-02-14T15:23:21.000Z","size":13,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-08T06:27:20.909Z","etag":null,"topics":["aws","aws-sdk-go","cloudformation","codedeploy","golang","lambda","sam","serverless"],"latest_commit_sha":null,"homepage":"","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/glassechidna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2019-08-15T12:03:35.000Z","updated_at":"2022-03-21T01:37:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"e7e9ff69-63da-40ea-8236-fd72bdc1b236","html_url":"https://github.com/glassechidna/codedeployhook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glassechidna%2Fcodedeployhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glassechidna%2Fcodedeployhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glassechidna%2Fcodedeployhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glassechidna%2Fcodedeployhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glassechidna","download_url":"https://codeload.github.com/glassechidna/codedeployhook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240698540,"owners_count":19843412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-sdk-go","cloudformation","codedeploy","golang","lambda","sam","serverless"],"created_at":"2025-01-08T06:23:16.702Z","updated_at":"2026-04-29T16:39:41.607Z","avatar_url":"https://github.com/glassechidna.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Safe AWS Serverless website deployments made easy\n\nThe [AWS Serverless Application Model][sam] (SAM) defines a simplified framework\non top of CloudFormation for building serverless apps. It has great support for\n[safe deployments][safe-doc] and is well-documented. This safe deployment functionality\nworks for a Lambda in _any_ scenario - not just websites. As such, it's very\ngeneral-purpose. This flexibility comes at the cost of having to reinvent a\npretty common wheel. That's where this app comes in.\n\n## How it works\n\nWhen configured as a `PreTraffic` \"hook\" for your `AWS::Serverless::Function`, \nthe following happens during a `sam deploy`:\n\n* New _version_ of Lambda function is published. No traffic is going to it\n  yet. The function's _alias_ is still sending 100% of traffic to the previous\n  version. \n\n* CloudFormation notifies CodeDeploy that there is a new version of the function\n  ready to start receiving traffic.\n  \n* CodeDeploy invokes the pre-traffic hook (**this** app) and tells it that\n  it's ready to start the traffic shifting. At this point no traffic has been\n  shifted yet.\n  \n* This app interprets the CodeDeploy hook payload to figure out which version\n  of your function has just been deployed. It then invokes the new function \n  version with a `GET /healthcheck` request in API Gateway* format.\n  \n* If the new code version return a 2xx-3xx: success! This app notifies CodeDeploy\n  that the new function version is good to be deployed.\n  \n* CodeDeploy now starts shifting traffic to the new version at the rate defined\n  in your `DeploymentPreference.Type` property.\n  \n* Alternatively, if the new function code did **not** return a 2xx or 3xx, it is\n  considered non-viable and this app notifies CodeDeploy that it's no good.\n  \n* CodeDeploy marks the deployment as failed, reports back to CloudFormation and\n  the stack is rolled back.\n\n## Installation\n\nThe app is installable through the [Serverless App Repository][sar]. It's named\n`codedeployhook` and ARN is `arn:aws:serverlessrepo:us-east-1:607481581596:applications/codedeployhook`.\n\n## Usage\n\nYou should modify your `AWS::Serverless::Function` resources to look like this\n(if they're a website!):\n\n```yaml\n  Function:\n    Type: AWS::Serverless::Function\n    Properties:\n      Handler: index.handler\n      Runtime: python3.7\n      Events:\n        Api:\n          Type: Api\n      # now add the following\n      AutoPublishAlias: live\n      DeploymentPreference:\n        Type: AllAtOnce\n        Role: !ImportValue ServerlessDeploymentRoleArn\n        Hooks:\n          PreTraffic: !ImportValue PreTrafficHook      \n```\n\n## Roadmap\n\n* Right now, the app assumes your serverless template only has a single function\n  with a `DeploymentPreference` configured. If you have multiple functions in a\n  single template, only the first will be checked. This will change to check all \n  configured functions concurrently.\n \n[sam]: https://github.com/awslabs/serverless-application-model\n[safe-doc]: https://github.com/awslabs/serverless-application-model/blob/master/docs/safe_lambda_deployments.rst#traffic-shifting-using-codedeploy\n[sar]: https://console.aws.amazon.com/lambda/home?region=us-east-1#/create/app?applicationId=arn:aws:serverlessrepo:us-east-1:607481581596:applications/sam-alb\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglassechidna%2Fcodedeployhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglassechidna%2Fcodedeployhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglassechidna%2Fcodedeployhook/lists"}