How to turn on/off cloud instances during office hours

前端 未结 9 1812
孤城傲影
孤城傲影 2020-12-08 10:40

I\'ve got my head around creating cloud instances in AWS, Azure and Rackspace. However, I need to turn my instances off at the end of the day and on in the morning as this w

相关标签:
9条回答
  • 2020-12-08 11:33

    Recommended solution for AWS:

    The AWS Data Pipeline is uniquely suited to this task. Data Pipeline uses AWS technologies and can be configured to run AWS CLI commands on a set schedule with no external dependencies. Data Pipeline can write logs to S3 and runs in the context of an IAM role, which eliminates key management requirements. Data Pipeline is also cost effective; for example, the Data Pipeline free tier can be used to stop and start instances once per day.

    https://aws.amazon.com/premiumsupport/knowledge-center/stop-start-ec2-instances/

    0 讨论(0)
  • 2020-12-08 11:36

    Old thread I know, but Microsoft introduced 'Runbooks' for Azure in 2014 that you can use for automation, including scheduled startups and shutdowns. As mentioned above, be sure you are in stopped (deallocated) state, as opposed to just stopped, in order to prevent charges.

    More info:

    Script to stop your VMs

    Azure automation, official MS docs.

    0 讨论(0)
  • 2020-12-08 11:38

    Approach

    You could always roll your own solution, insofar most cloud providers offer a respective API to start/stop instances on demand (or even on schedule), which is what those management services are actually using as well of course - the AmazonEC2 Java interface offers all relevant methods for example (amongst many others), specifically:

    • StartInstances()
    • StopInstances()
    • RebootInstances()

    Via Scripting (EC2)

    The most simple approach for this regarding Amazon EC2 would be to craft yourself some Python scripts by means of the excellent boto (An integrated interface to current and future infrastructural services offered by Amazon Web Services), which exposes all EC2 methods mentioned above; you could then start those scripts on demand or via your operating system scheduler.

    Via Continuous Integration / Automation (EC2)

    Another option would be to facilitate a continuous integration server as an automation engine (a sometimes overlooked aspect of these systems), in case you happen to run one anyway; it would allow you to both start/stop instances on demand or scheduled similar to cron.

    We do exactly this by means of the Bamboo AWS Plugin (it's Open Source and the code is available on Bitbucket), see my answer to How to start and stop an Amazon EC2 instance programmatically in java for more details on this approach. While Atlassian Bamboo is a commercial offering, there should be something similar available for popular Open Source CI solutions like e.g. Jenkins as well.

    0 讨论(0)
提交回复
热议问题