All Projects → nib-health-funds → hammertime

nib-health-funds / hammertime

Licence: MIT license
AWS EC2, ASG, RDS Power cycling

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to hammertime

py-spotme
A CLI tool that creates AWS spot instances on the fly
Stars: ✭ 16 (+33.33%)
Mutual labels:  ec2, ec2-instance
Aws.ec2
AWS EC2 Client Package
Stars: ✭ 47 (+291.67%)
Mutual labels:  ec2, aws-ec2
AutoSpotting
Saves up to 90% of AWS EC2 costs by automating the use of spot instances on existing AutoScaling groups. Installs in minutes using CloudFormation or Terraform. Convenient to deploy at scale using StackSets. Uses tagging to avoid launch configuration changes. Automated spot termination handling. Reliable fallback to on-demand instances.
Stars: ✭ 2,058 (+17050%)
Mutual labels:  ec2, ec2-instance
Amazon Ec2 Instance Selector
A CLI tool and go library which recommends instance types based on resource criteria like vcpus and memory
Stars: ✭ 146 (+1116.67%)
Mutual labels:  ec2, aws-ec2
sigil
AWS SSM Session manager client
Stars: ✭ 67 (+458.33%)
Mutual labels:  aws-ec2, ec2-instance
ecs-autoscale
A framework that runs on AWS Lambda for autoscaling ECS clusters and services
Stars: ✭ 69 (+475%)
Mutual labels:  ec2, aws-ec2
Spark Jupyter Aws
A guide on how to set up Jupyter with Pyspark painlessly on AWS EC2 clusters, with S3 I/O support
Stars: ✭ 259 (+2058.33%)
Mutual labels:  ec2, aws-ec2
Autospotting
Saves up to 90% of AWS EC2 costs by automating the use of spot instances on existing AutoScaling groups. Installs in minutes using CloudFormation or Terraform. Convenient to deploy at scale using StackSets. Uses tagging to avoid launch configuration changes. Automated spot termination handling. Reliable fallback to on-demand instances.
Stars: ✭ 2,014 (+16683.33%)
Mutual labels:  ec2, ec2-instance
amazon-cloudwatch-auto-alarms
Automatically create and configure Amazon CloudWatch alarms for EC2 instances, RDS, and AWS Lambda using tags for standard and custom CloudWatch Metrics.
Stars: ✭ 52 (+333.33%)
Mutual labels:  ec2, aws-ec2
stork
Retrieve tokens from Vault for your EC2 instances.
Stars: ✭ 12 (+0%)
Mutual labels:  ec2, ec2-instance
ec2-metadata-filter
Enhance the security of the EC2 metadata service. (Obsolete thanks to Instance Metadata Service Version 2, see note in README)
Stars: ✭ 32 (+166.67%)
Mutual labels:  ec2, aws-ec2
serverless-go-graphql
Serverless Framework template with Golang, GraphQL and DynamoDB
Stars: ✭ 28 (+133.33%)
Mutual labels:  serverless-framework
tech1-temple-aws
AWS Proofs of Concepts repository. No Longer Supported
Stars: ✭ 32 (+166.67%)
Mutual labels:  ec2
bitbucket-to-aws
How to deploy a Laravel app from Bitbucket to autoscaled instances at AWS.
Stars: ✭ 14 (+16.67%)
Mutual labels:  ec2
aws-serverless-swift-api-template
A Serverless REST API template, implemented in Swift with swift-aws-lambda-runtime.
Stars: ✭ 42 (+250%)
Mutual labels:  serverless-framework
pnzr
pnzr is docker deploy tool for ecs.
Stars: ✭ 31 (+158.33%)
Mutual labels:  ec2
express-sls-app
How to deploy a Node.js application to AWS Lambda using Serverless, a quick start.
Stars: ✭ 20 (+66.67%)
Mutual labels:  serverless-framework
serverless-cloudformation-sub-variables
Serverless framework plugin for easily supporting AWS CloudFormation Sub intrinsic function variables
Stars: ✭ 25 (+108.33%)
Mutual labels:  serverless-framework
terraform-aws-ec2-instance
Terraform module for provisioning a general purpose EC2 host
Stars: ✭ 123 (+925%)
Mutual labels:  ec2
triggerflow
Event-based Orchestration of Serverless Workflows
Stars: ✭ 38 (+216.67%)
Mutual labels:  serverless-framework

Build Status codecov

hammertime

Build Status

Serverless power cycling for AWS EC2, RDS instances, Auto Scaling Groups, and Fargate based on a schedule.

Stop! Hammer Time!

RDS Limitations

According to AWS RDS User Guide the following are the limitations to stopping and starting RDS instances:

One can't stop a DB instance that has a Read Replica, or that is a Read Replica. One can't stop a DB instance that is in a Multi-AZ deployment. One can't stop a DB instance that uses Microsoft SQL Server Mirroring.

Hammertime will automatically filter out RDS instances with the above conditions.

Getting Started

Edit serverless.yml where you can adjust

  • scheduled run time,
  • deployment s3 bucket (can be set as DEPLOY_BUCKET env var),
  • AWS region,
  • stage between dev/test/production/other (can be set as SLICE env var),
  • anything else which takes your fancy.

Usage

stop-hammertime will stop all EC2 instances that are not in an ASG, it will also set the desired instance count of all ASGs to 0; unless the mentioned assets are tagged with one of the following supported hammertime tags:

  • hammertime:canttouchthis: Will prevent hammertime from starting or stopping this asset in all cases.
  • hammertime:canttouchthisbetween: Will prevent hammertime from starting or stopping the asset between a given time range specified in the value of the tag. The expected format for the value is {datetime} and {datetime} For example: A value of 2017-05-06 and 2017-06-06 prevents hammertime from affecting this asset between the mentioned dates. The datetimes should be a valid ISO-8601 string.
  • hammertime:canttouchthisbefore: Will prevent hammertime from affecting the asset before a specific datetime represented in the value field of the tag. The datetime should be a valid ISO-8601 string. For example: A value of 2017-05-06 will ensure the given asset is not touched before the given date.

start-hammertime will query the tags left by stop-hammertime and return the instances and ASGs to their previous status.

Hammertime is intended to be run in response to a Lambda scheduled event, e.g

stop-hammertime: run Monday-Sunday at 6PM (UTC timezone by default, see here on how to customise this)

start-hammertime: run Monday-Sunday at 6AM (UTC timezone by default, see here on how to customise this)

Enabling/Disabling

You can enable/disable hammertime using the environment variable HAMMERTIME_ENABLED at the time of deployment. 'true' enables hammertime.

Dry run

Hammertime has a dry-run feature for when you are not quite ready to unleash the hammer pants on your entire fleet of EC2s just yet. By setting HAMMERTIME_DRY_RUN to 'true', you enable dry-run in which hammertime does not touch your EC2s but will still log what it would have touched.

Timezones

Hammertime can run against assets that require a different uptime schedule due to the timezone that they might operate in. Have teams that work in different timezones on their owns assets, then this festure is for you! When deploying hammertime, set the environment variable HAMMERTIME_OPERATING_TIMEZONES, list any amount of valid IANA timezones, deliminated by a , that you would like hammertime to support, for example Australia/Sydney,Pacific/Auckland. A list of these can be found on wikipedia. Hammertime will now deploy with START and STOP crons in each of the listed timezones.

Once you have hammertime configured to run with multiple CRONS, tag your assets with hammertime:operatingtimezone, with a value that is one of the IANA timezone strings, for the example above that would either be Australia/Sydney or Pacific/Auckland. For untagged assets, hammertime will use a default operating timezone (UTC by default, see )

Changing the defaults

Changing the default start and stop hour

By default, hammertime deploys with the default start hour and stop hour set to 6 and 19 respectively to start and stop instances at 6am and stop at 6pm. To change these, set the environment variables HAMMERTIME_START_HOUR and HAMMERTIME_STOP_HOUR when deploying to change the hours that hammertime will start/stop assets.

Changing the default timezone

By default, hammertime deploys with the default operating timezone UTC, this can be overidden by setting the HAMMERTIME_DEFAULT_OPERATING_TIMEZONE environment variable when deploying. Set this to a valid IANA timezone, for example Australia/Sydney.

Limitations

Due to scheduling hammertime using AWS crons, we are unable to dynamically adjust the cron to take into account timezones that shift offsets, for example timezones that implement daylight savings time (DST). To remedy this, re-deploy hammertime when your timezone offset shifts to recreate the crons to have the updated shift in offset.

Deployment

Refer to the serverless framework for detailed instructions, but should be as simple as

  • Install dependencies
npm i
  • Transpile the code
npm run build
  • Authenticate with AWS via your favourite CLI

  • then deploy

npm run deploy

Built With

  • serverless framework

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the releases on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].