{"id":36846449,"url":"https://github.com/paybyphone/asg53","last_synced_at":"2026-01-12T14:33:12.821Z","repository":{"id":57610516,"uuid":"73593225","full_name":"paybyphone/asg53","owner":"paybyphone","description":"AWS Lambda function for making Route 53 changes via ASG lifecycle hooks","archived":false,"fork":false,"pushed_at":"2016-11-18T01:07:46.000Z","size":485,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T17:35:22.213Z","etag":null,"topics":["aws-autoscaling","aws-lambda","go","route53"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paybyphone.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":"2016-11-13T03:27:47.000Z","updated_at":"2024-06-20T17:35:22.214Z","dependencies_parsed_at":"2022-09-26T20:02:14.756Z","dependency_job_id":null,"html_url":"https://github.com/paybyphone/asg53","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/paybyphone/asg53","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paybyphone%2Fasg53","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paybyphone%2Fasg53/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paybyphone%2Fasg53/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paybyphone%2Fasg53/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paybyphone","download_url":"https://codeload.github.com/paybyphone/asg53/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paybyphone%2Fasg53/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28340400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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-autoscaling","aws-lambda","go","route53"],"created_at":"2026-01-12T14:33:11.858Z","updated_at":"2026-01-12T14:33:12.810Z","avatar_url":"https://github.com/paybyphone.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# asg53\n\n`asg53` is a tool for [AWS Lambda][1] that allows one to process\n[EC2 Auto-Scaling][2] events and make modifications in [Route 53][3]. It is\nintended for use with SNS, and uses data-driven JSON representations of Route 53\nchange batches that can be customized with [Go templates][4], supplied as\nnotification metadata.\n\n## Building\n\nThis is a Go-based Lambda function, and hence needs to be wrapped with a shim.\nWe use [aws-lambda-go][5], which also provides a Docker container with access\nto the toolchain.\n\nFollow the directions below to build:\n\n```\ngo get github.com/paybyphone/asg53\ncd $GOPATH/src/github.com/paybyphone/asg53\ndocker run --rm -v $GOPATH:$GOPATH -e GOPATH=$GOPATH -w `pwd` eawsy/aws-lambda-go\n```\n\nAfter the build is complete, upload the `handler.zip` file to Lambda.\n\n## Usage\n\nFirst you will want to read up on how to configure [Lifecycle Hooks][6] for Auto\nScaling. This is a moderately complex process that may be documented here later.\n\nThe Lambda function's role needs the following policy attached to it:\n\n```\n{\n    \"Version\": \"2012-10-17\",\n    \"Statement\": [\n        {\n            \"Sid\": \"\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"route53:ListResourceRecordSets\",\n                \"route53:ChangeResourceRecordSets\"\n            ],\n            \"Resource\": \"arn:aws:route53:::hostedzone/HOSTEDZONEID\"\n        },\n        {\n            \"Sid\": \"\",\n            \"Effect\": \"Allow\",\n            \"Action\": \"route53:GetChange\",\n            \"Resource\": \"arn:aws:route53:::change/*\"\n        },\n        {\n            \"Sid\": \"\",\n            \"Effect\": \"Allow\",\n            \"Action\": \"ec2:DescribeInstances\",\n            \"Resource\": \"*\"\n        },\n        {\n            \"Sid\": \"\",\n            \"Effect\": \"Allow\",\n            \"Action\": \"autoscaling:CompleteLifecycleAction\",\n            \"Resource\": \"*\"\n        },\n        {\n            \"Sid\": \"\",\n            \"Effect\": \"Allow\",\n            \"Action\": [\n                \"logs:PutLogEvents\",\n                \"logs:DescribeLogStreams\",\n                \"logs:CreateLogStream\",\n                \"logs:CreateLogGroup\"\n            ],\n            \"Resource\": \"arn:aws:logs:*:*:*\"\n        }\n    ]\n}\n```\n\nNext, when creating your lifecycle hooks, you will want to structure your\nnotification metadata in the JSON format below. For example, this metadata set\ncould create a route 53 resource record for an instance while it's being\nlaunched:\n\n```\n{\n  \"HostedZoneID\": \"HOSTEDZONEID\",\n  \"Changes\": [\n    {\n      \"Action\": \"UPSERT\",\n      \"ResourceRecordSet\": {\n        \"Name\": \"{{.InstanceID}}.example.com.\",\n        \"TTL\": 3600,\n        \"Type\": \"A\",\n        \"ResourceRecords\": [\n          {\n            \"Value\": \"{{.InstancePublicIPAddress}}\"\n          }\n        ]\n      }\n    }\n  ]\n}\n```\n\nAnd this can be added to a termination event to delete the record.\n\n```\n{\n  \"HostedZoneID\": \"HOSTEDZONEID\",\n  \"Changes\": [\n    {\n      \"Action\": \"DELETE\",\n      \"ResourceRecordSet\": {\n        \"Name\": \"{{.InstanceID}}.example.com.\",\n        \"TTL\": 3600,\n        \"Type\": \"A\",\n        \"ResourceRecords\": [\n          {\n            \"Value\": \"{{.ExistingRDataValue 0 0}}\"\n          }\n        ]\n      }\n    }\n  ]\n}\n```\n\n## How it Works\n\nIn the metadata you are supplying the hosted zone ID to act on, in addition to a\nRoute 53 change batch. The same rules apply to the latter as they would when\nusing the CLI, so see [there][6] for more details.\n\nThe function can operate on both `autoscaling:EC2_INSTANCE_LAUNCHING` or\n`autoscaling:EC2_INSTANCE_TERMINATING` - the function does not handle one or\nthe other in any special way. The only caveat is that you need to be cognizant\nof when you are processing termination events, as certain template fields won't\nbe available (see below).\n\n## Template Reference\n\nThe data is driven by Go tempalte values (using a double-curly bracer closure -\n`{{}}`) that allows you to access specific fields related to the instance.\n\nNote that fields are interpolated on `Name` and `Value` fields only (the latter\nin the `ResourceRecords` list).\n\nCurrent fields are:\n\n * `{{.InstanceID}}`, for the instance ID\n * `{{.InstancePrivateIPAddress}}`, for the instance's private IP address\n * `{{.InstancePublicIPAddress}}`, for the instance's public IP address\n * `{{.ExistingRDataValue [set] [record]}}`, to get the existing RDATA\n   on a resource record set. This function operates on the existing\n   change set, performing a Route 53 `ListResourceRecordSets` request\n   looking for the record specified in the `Name` field of the change\n   specified by `set`, returning the `ResourceRecord` `Value` at the\n   index specified by `record`. It should be noted that the function is called\n   on the change set as it currently exists. This means that whether or not a\n   properly rendered `Name` field exists depends on where this function is\n   called - if called too early on a field that has not yet been iterated on,\n   the templated data will be incomplete. Lookups that result in no data\n   returned, an out of range value index, or a Route 53 API error will cause\n   an error.\n\n### Note on terminating instances\n\nNote that on termination events, IP address values will be rendered as\nempty strings, so take care when using DELETE events that you don't\nattempt to delete a non-existent, or even worse, an incorrect, record.\nUse `ExistingRDataValue` to locate the existing resource record for the\nvalue instead (as explained in the main example).\n\n## License\n\n```\nCopyright 2016 PayByPhone Technologies, Inc.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n[1]: https://aws.amazon.com/lambda/\n[2]: https://aws.amazon.com/autoscaling/\n[3]: https://aws.amazon.com/route53/\n[4]: https://golang.org/pkg/text/template/\n[5]: https://github.com/eawsy/aws-lambda-go\n[6]: http://docs.aws.amazon.com/autoscaling/latest/userguide/lifecycle-hooks.html\n[7]: http://docs.aws.amazon.com/cli/latest/reference/route53/change-resource-record-sets.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaybyphone%2Fasg53","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaybyphone%2Fasg53","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaybyphone%2Fasg53/lists"}