Traditionally, there has been a window of time during software deployments when servers are incapable of serving production traffic. This window is typically scheduled for early morning off-hours to minimize downtime, but it still impacts availability. Zero-downtime deployment (ZDD) is the practice of keeping services always running and available to customers, even during software updates. If a ZDD is executed well, users should not be aware when changes are being made to the system.
In this chapter, we investigate three approaches to achieving ZDDs with Terraform. First, we use the create_before_destroy
meta attribute to ensure that an application is running and passing health checks before we tear down the old instance. The create_before_destroy
meta attribute alters how force-new updates are handled internally by Terraform. When it’s set to true
, interesting and unexpected behavior can result.