A CDK construct that will automatically start a stopped EC2 instance at a given time.
Project description
Wakeywakey!
Do you have a EC2 instance that you only need during certain hours of the day? Do you want to reduce it's cost? Are you using the @matthewbonig/nightynight construct to shut it down every night? Do you want to start it up in the morning?
That's the Wakeywakey 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 stopped, it is started.
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 start the instance if it's in a stopped state.
Example:
# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
class WakeyWakeyStack(Stack):
def __init__(self, scope, id, props):
super().__init__(scope, id, props)
# The code that defines your stack goes here
WakeyWakey(self, "nighty-night", instance_id="i-123123123123")
This will start 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
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.wakeywakey-1.78.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb089b4345afe9cb166a9ea2cca6debcc21074cd2388a271fd1047f64eeab567 |
|
MD5 | 9ba0f57d7ddded60a3f368f32cc1f963 |
|
BLAKE2b-256 | 8093a82fd8097cec26c6f0c2787a5766e35c4e567b061353ebbb6ae45b57287b |