问题
Assuming a cloud infrastructure across multiple cloud provider accounts (AWS, Azure and GC) built with Terraform. Is there any way to reboot instances using Terraform? If not, how do people easily and centrally reboot their instances created with Terraform?
Thanks!
回答1:
Terraform does not provide capacity to reboot your instances. At best, you could taint a resource, that means that terraform will destroy and recreate (which is obviously not the same the rebooting). Terraform is not the right tool to manage the lifecycle of your instance.
Usually, the best practice is to get your instance automatically rebooted, using cloudwatch on AWS. You need to configure it to detect unhealthy instances. I guess other cloud providers have a similar feature.
If you need to do it manually, next step would be to use the cloud API (such as aws cli) to perform this action. I am not aware of a tool that let you do that across cloud providers centrally.
来源:https://stackoverflow.com/questions/49317110/start-stop-instances-across-multiple-cloud-providers