NightyNight and WakeyWakey!
Do you have a EC2 instance or an RDS 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.
There are currently two variations of the construct:
- NightyNightForEc2 - stops an EC2 instance at a given time.
- NightyNightForRds - stops an RDS instance at a given time.
- NightyNightForAsg - sets the desired capacity for an ASG at a given time.
- NightyNightForEcs - sets the desired capacity for an ECS service at a given time.
WakeyWakey
The WakeyWakey construct (from this repository) has been integrated into this library. You don't need to install a separate dependency anymore.
- WakeyWakeyForEc2 - start an EC2 instance at a given time.
- WakeyWakeyForRds - start an RDS instance at a given time.
There isn't a specific construct for starting ASGs or ECS services, since you can just set the count to whatever you want.
This is a pre-release!
This is a quick first-draft. All the options that will likely need to be added to accommodate 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.
There are multiple versions of this library published. You should be using the v0.X.X versions for now. There are versions published that match the CDK version they depend on, but don't use those.
What it 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
instanceIdand then stop the instance if it's in a running state.
Example:
import {NightyNightForEc2, WakeyWakeyForEc2} from "./ec2";
export class NightyNightStack extends Stack {
constructor(scope: Construct, id: string, props: StackProps) {
super(scope, id, props);
// The code that defines your stack goes here
new NightyNightForEc2(this, 'nighty-night', {instanceId: 'i-123123123123'});
new WakeyWakeyForEc2(this, 'wakey-wakey', {instanceId: 'i-123123123123'})
}
}
This will stop the instance with id i-123123123123 at (the default) 4am UTC. It will then start the instance at 12am UTC.
API Doc
See the API Docs for more info.
Contributing
Please open Pull Requests and Issues on the Github Repo.
License
MIT
Metadata
Release files for mbonig.nightynight 2.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mbonig.nightynight-2.0.4.tar.gz | 27.3 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mbonig.nightynight-2.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.6 MB
Release files / mbonig.nightynight-2.0.4.tar.gz
| Download URL | mbonig.nightynight-2.0.4.tar.gz |
|---|---|
| Size | 27.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f44f9f94c0450b429e94c3f23238d7fa28729a33fa3f59e59eca6f793eec2c67
|
|
BLAKE2b-256 checksum How to use checksums |
ebbd8a09d6b6c24b29dd94db8d9e7a5ad970c440342b4e80b5b306f9120fbdba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / mbonig.nightynight-2.0.4-py3-none-any.whl
| Download URL | mbonig.nightynight-2.0.4-py3-none-any.whl |
|---|---|
| Size | 27.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a07b31fa53e6890a2e4d92d1dc8027fc74a05b8f71350d959ad8be2b63efc99e
|
|
BLAKE2b-256 checksum How to use checksums |
c1bf6cd575b6086f72b39f545ccecc283d8ce838342b40e0407a3841d19faa45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Security for mbonig.nightynight 2.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.