Skip to main content

shutdown and startup AWS CloudFormation EC2 and RDS instances

Project description

AWS CloudFormation power switch

AWS CloudFormation power switch allows you to shutdown and startup all EC2, RDS and AutoScaling instances managed by one or more CloudFormation stacks.

install the power switch

to install the power switch, type:

pip install aws-cloudformation-power-switch

shutdown

to shutdown all instances managed by CloudFormation stacks starting with the name dev, type:

aws-cfn-power-switch --dry-run --stack-name-prefix dev shutdown

This will show you which EC2, RDS and AutoScaling instances will be shutdown. For Auto Scaling groups, the desired number of instances is set to 0. If the minimum is greater than 0, it will change the minimum setting too.

startup`

to startup all instances managed by a CloudFormation stacks starting with the name dev, type:

aws-cfn-power-switch --dry-run --stack-name-prefix dev startup

This will show you which EC2, RDS and AutoScaling instances will be started. The AutoScaling desired number of instances will be set the maximum desired instances.

deploy the power switch

To deploy the power switch as an AWS Lambda, type:

git clone https://github.com/binxio/aws-cloudwatch-log-minder.git
cd aws-cloudwatch-log-minder
aws cloudformation deploy \
	--capabilities CAPABILITY_IAM \
	--stack-name aws-cloudformation-power-switch \
	--template-file ./cloudformation/aws-cloudformation-power-switch.yaml \
    --override-parameters \
        StackNamePrefix=dev \
	    "Startup=cron(30 7 ? * MON-FRI *)" \
        "Shutdown=cron(30 23 ? * MON-FRI *)"

This will shutdown down all EC2, RDS and Auto Scaling instances managed by CloudFormation stacks starting with the name dev at 23:30 and start them backup at 7:30 in the morning.

verbose

export LOG_LEVEL=INFO
cwlog-minder ...

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

aws-cloudformation-power-switch-0.1.5.tar.gz (6.0 kB view details)

Uploaded Source

File details

Details for the file aws-cloudformation-power-switch-0.1.5.tar.gz.

File metadata

  • Download URL: aws-cloudformation-power-switch-0.1.5.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.5

File hashes

Hashes for aws-cloudformation-power-switch-0.1.5.tar.gz
Algorithm Hash digest
SHA256 3ac5ebfa5745d54f73f73b5211ef3c98b56e0ff48909d598c3c564f999a4e1cf
MD5 bfdf1ab3e4b6a1cb545ed12b25e1a04f
BLAKE2b-256 f14abad466828d9ba63a38b630ef3639a97a0b3e08926c27d59ed8a91e612124

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