resource shutdown terraform Archives - For all your terraform needs https://terraformarchitect.com/tag/resource-shutdown-terraform/ Automation cannot be an afterthought (TM) Tue, 22 Aug 2023 13:31:40 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 Resource Shutdown via terraform https://terraformarchitect.com/quick-recipes-terraform/resource-shutdown-via-terraform/?utm_source=rss&utm_medium=rss&utm_campaign=resource-shutdown-via-terraform https://terraformarchitect.com/quick-recipes-terraform/resource-shutdown-via-terraform/#respond Tue, 22 Aug 2023 13:31:40 +0000 https://terraformarchitect.com/?p=372 Terraform is often used to destroy environments – which keeps the state file consistent, when the next create event needs to occur. However, sometimes, instead of destroying resources, all you […]

The post Resource Shutdown via terraform appeared first on For all your terraform needs.

]]>
Terraform is often used to destroy environments – which keeps the state file consistent, when the next create event needs to occur.

However, sometimes, instead of destroying resources, all you want to do is shut them down or disable them. This is also doable using remote-exec in terraform

Shutting down an EC2 instance on aws

resource "aws_instance" "app" {
  # ...

  provisioner "remote-exec" {
    when    = "destroy"
    inline = [ "systemctl stop service" ]
  }
}

The post Resource Shutdown via terraform appeared first on For all your terraform needs.

]]>
https://terraformarchitect.com/quick-recipes-terraform/resource-shutdown-via-terraform/feed/ 0