https://github.com/zonkyio/lambda-ec2handler
https://github.com/zonkyio/lambda-ec2handler
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/zonkyio/lambda-ec2handler
- Owner: zonkyio
- License: bsd-2-clause
- Created: 2018-05-03T13:08:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-09T13:39:10.000Z (over 7 years ago)
- Last Synced: 2025-08-01T01:08:09.036Z (3 months ago)
- Language: Python
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
AWS Lambda ec2 handler
======================This repo contain python lambda scripts (in path ./files/source), Makefile to build python36 package and could work as terraform module.
Terminate function
==================
When cloudWatch receives event "ec2 terminate" notify the lambda-ec2handler-terminate lambda function. This lambda function check if instance has tag "source" equals to "jenkinsDockerBuild", create url api.EC2_INSTANCE_NAME.example.com and check if this url has CNAME, and if it does not listen on HTTP protocol. If all requirements are fullfiled, the script try to delete records belonged to instance in defined zone in route53 service.Script requirements
-------------------
* python 3.6
* pip3
* boto3
* Linux/BSD/OSX os to be able run make and installation by terraformInstalation
-----------
this repo work as a terraform module and in example bellow you could see how to use it in your terraform environment.module "lambda-ec2handler" {
source = "../modules/lambda-ec2handler"
tags = {
Env = "devel",
Zone = "eu-central-1",
Terraform = "True",
}
}Before run it as a module you should:
* check source code in files/source/terminate.py to fit lambda_handler function to your usecase (at least change _______EXAMPLE.COM_______ to your domain).
* build files/python36_env.zip by run make command in this directory (begin with **make help**)After installation there are a few steps I didn't add to terraform (sorry for that):
* in lambda designer add "CloudWatch Event" to trigers and save function