Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Element84/cloudwatch-deregister-ec2-hosts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This is a Lambda function, triggered by a CloudWatch event. When an EC2 instance is terminated, such as during an auto-scaling event, the network information of the server is sent to the Lambda function and it is de-registered from the directory service.

At Element 84, we use FreeIPA, and we've provided an example CloudFormation stack to deploy the CloudWatch event, IAM role, and Lambda.

Make sure your Lambda has access to your directory server, which probably requires it to run within a VPC and have appropriate network routes available.

The main script can be found under functions/freeipa/remove_host.py

Installation / Setup

As this is Lambda, you need to install the libraries prior to zipping into a Lambda deployment package.

Install dependencies

pip install git+https://github.com/Element84/python-freeipa-json.git -t .

This will install the dependencies into the project root, necessary for Lambda. The libraries themselves and lambda.zip have been added to .gitignore, so make sure to run the pip step prior to creating the zip package.

We currently have forked the FreeIPA-JSON repo to work with our Python3 project and plan to contribute back to the upstream FreeIPA-JSON project for Py3 support.

Create Lambda zip

zip -r lambda.zip . to create the Lambda package.

TODO

  • Cloudformation
  • Add tests

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages