Skip to main content

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

arch.png

  • 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mbonig.nightynight-1.85.3.tar.gz (109.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mbonig.nightynight-1.85.3-py3-none-any.whl (108.5 kB view details)

Uploaded Python 3

File details

Details for the file mbonig.nightynight-1.85.3.tar.gz.

File metadata

  • Download URL: mbonig.nightynight-1.85.3.tar.gz
  • Upload date:
  • Size: 109.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

File hashes

Hashes for mbonig.nightynight-1.85.3.tar.gz
Algorithm Hash digest
SHA256 42d4be50aa1190d998282a6bd29891caadaedc8cd106126332a507194bfa35a9
MD5 c74d6893d570ec20d8ebdb7dfab62f12
BLAKE2b-256 06ab85e58937aceed31a80bd79200f3c6c18069a45c515f597d10b0e177dd994

See more details on using hashes here.

File details

Details for the file mbonig.nightynight-1.85.3-py3-none-any.whl.

File metadata

  • Download URL: mbonig.nightynight-1.85.3-py3-none-any.whl
  • Upload date:
  • Size: 108.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

File hashes

Hashes for mbonig.nightynight-1.85.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3214c85846c75a8d478512c427e8cda5935051121e5500de0db9d272516678a8
MD5 8c96178e2db68f5ef5fbb30730c933de
BLAKE2b-256 da82d03e8e06866a6aae59f6014ee7f7bec875bea4f4e43fe6d69fc9c332cd0e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page