Home
Blog
Multi-Environment Deployment Workflow with env zero's Terraform Provider

Multi-Environment Deployment Workflow with env zero's Terraform Provider

Andrew Way
Sales Engineering
with special guest
Mitchell
Hashimoto
Mitchell Hashimoto headshot

Infrastructure is typically built up from multiple layers, starting with the network to the compute layer. In order to deploy your K8s cluster, you typically need your subnets and VPCs defined ahead of time. As I talk to customers about their IaC deployment challenges, I often get asked how envzero can help with orchestrating dependencies amongst these multi-tiered, multi-layered infrastructure deployments.

Today, I’d like to share how a simple, yet powerful, tweak to our TF provider env0_environment resource gives us a method of orchestrating these complex workflows. By introducing a “wait_for” flag in our env0_environment resource, we can now define multiple envzero environments that essentially depend on one another, and also ensure that they get deployed synchronously by Terraform.

Editor's Note:
This blog post is outdated; and the provider features described in the post have since been deprecated.
Please refer to our documentation and this blog post for more up-to-date information about envzero Workflows.

Background

envzero Terraform Provider

We’re excited to announce the release of v1.0 of our Terraform Provider! If you’re not familiar with the envzero Terraform Provider, it is simply a way to define your envzero configuration as Terraform code. We have resources for creating Projects, Templates, and most importantly, Environments. For example, this will allow you to create a project factory from within envzero as you onboard new teams.

Terraform lifecycle

Terraform has a “depends_on” meta-argument flag that helps you explicitly define resource dependencies. Typically, this is optional, as Terraform will automatically calculate the dependencies based on variable and module dependencies. However, with env0, Terraform doesn’t know about the environment dependencies, unless we explicitly use this flag. Even then, envzero environments will simply be deployed synchronously, despite the usage of “depends_on.”

Introducing the “wait_for” flag

By introducing the “wait_for” flag, we can force the envzero Terraform provider to wait for the environment creation before deploying the next resource.

Here’s a simple example of Terraform code that utilizes the wait feature (check the code here).

Here's a short video of what this looks like in real life.

Other Exciting Features in TF Provider 1.0 release

Schedule a technical demo
See env zero in action
Schedule demo

Related Content

All articles