|
After experimenting with SimianArmy/Janitor Monkey, I've determined that this is probably not the most suitable tool for what we need to do. It's much too broad, doesn't have too many options for granular configuration such the ability to apply filters, and doesn't include any kind of support for Route53 (cleaning up stale DNS entries). It did, however, provide me with some ideas on creating a custom script to do what we need to do. Utilizing the AWS CLI toolset (or the Python boto3 SDK) and the Github API we should be able to do the following:
- Search for instances with a tag called 'PR' with a value set to the Github PR number.
- Verify that the PR has either been merged or closed utilizing the Github API.
- If the PR has been closed, terminate the EC2 instance associated with the PR.
In this way, PR FOLIO instances will remain available until the PR is closed or merged. We must, however, account for the fact that there may/will be multiple builds of the same PRs and deal with that. Possibly terminating instances with the previous build numbers after a new instance is created.
We can also tag the instance with the hostname that was set for a particular instance and use the tag value to update Route53 (AWS hosted DNS) in order to prune stale DNS entries.
|