A CDK construct that will automatically stop a running EC2 instance at a given time.
Project description
NightyNight!
Do you have a EC2 instance that you only need during certain hours of the day? Do you want to reduce it's cost? How about just stopping it every night?
That's the NightyNight construct. It's very simple. Give it an instanceId
and it will create a Lambda and a CloudWatch Event Rule to fire the lambda at a specific time of day. If the instance is running, it's stopped.
This is a pre-release!
This is a quick first-draft. All the options that will likely need to be added to accomodate a large number of use-cases are still needed. If you'd like to make requests or help update this construct, please open an Issue or a PR.
What is creates
- A Rule that will, on a given schedule, fire a lambda.
- A Lambda with permissions to describe ec2 instances. It will read the instance by the given
instanceId
and then stop the instance if it's in a running state.
Example:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
class NightynightStack(Stack):
def __init__(self, scope, id, props):
super().__init__(scope, id, props)
# The code that defines your stack goes here
NightyNight(self, "nighty-night", instance_id="i-123123123123")
This will stop the instance with id i-123123123123
at (the default) 4am GMT.
Contributing
Please open Pull Requests and Issues on the Github Repo.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mbonig.nightynight-1.66.0.post2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd499612870267cfb91a5048e491a4526a8046262fc17f2810fd3df176166a80 |
|
MD5 | dc2589533d14a8bcaafaa51b0bf424c0 |
|
BLAKE2b-256 | 5ff85433f3f77a359a4dd04a132ce65bee721eff8fa1d2f78427c0fb6f7edaba |
Hashes for mbonig.nightynight-1.66.0.post2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dff721d612d1e5b36c7347bbdf5deb504e55988d264a5da327abd6a3af3e465 |
|
MD5 | 4adc8442f31e6c921609049e41862112 |
|
BLAKE2b-256 | 520504ef463b4cac6abd0e9a1f9aed26cc82bf042f59af50fbafd9a01aafd648 |