Why env0
Solutions
Infrastructure as Code (IaC) Automation Teams and GovernanceManaged Self-Service env0 for the Enterprise
DocumentationPricing
Resources
Case StudiesIn the NewsVideosWebinars
Blog
Login
Get a Demo
FREE TRIALContact us
Jul 1, 2022

env0 Workflows Get a Power Up

Kevin "KMac" Damaso
Technical Product Marketer

What’s changed with Workflows?

We’ve enhanced Workflows to make it simpler to deploy complex environments with dependencies.

A production app’s infrastructure comprises many resources. As those resources grow, managing and deploying them requires more thought and effort. 

These days we ‌look at managing infrastructure as we do application code — split a large whole into smaller, more manageable pieces where each piece is cohesive and loosely coupled.

In theory, this textbook solution sounds great because each resource is independent and can be deployed at any time.

But in the real world, we have dependencies which make deploying those resources simultaneously impractical.

Example

A "Network and VPC" manages the ‌network configuration.

"DB" manages a database that multiple services use.

"EKS" manages the Elastic Kubernetes Service where pods of services will be deployed.

"Billing Service"", "Configuration Service" and "Notification Service" all manage the deployments of services on EKS. Those services need access to the database.

 For this use case:

"DB" depends on the VPC from the "Network and VPC" IaC stack."EKS" also depends on the VPC from the "Network and VPC" IaC stack.All service environments depend on DB, and EKS

As can be seen, the dependencies make it impossible for all the Environments to be deployed simultaneously. Additionally, these are Kubernetes based deployments with multiple frameworks that have traditionally required complex integrations between the workflows.

As the resources and environments grow, the complexity of the dependencies will also exponentially increase.

Current State

Splitting a large infrastructure set is encouraged as a best practice to reap the benefits of a microservices architecture.

We see many DevOps teams implement this technique in IaC by splitting up the application into either a) Layers or b) Phases/Dependencies.

Layers

Sometimes cloud resources are ‌too expensive or slow to provision, or have strict, low and hard limits on instances per account.

If a resource or group of resources have one or several of these characteristics, it is often extracted to a separate stack that has to be deployed once per cloud account and reused by multiple other stacks (for example: think of a typical CloudFront distribution which usually takes 15-30 minutes to provision).

Although a common use case, most CD pipeline solutions do not have a first-class solution for it. 

Phases/Dependencies

Another common pattern is one where a different prerequisite stack instance is required for each environment.

This case is much more commonly supported by most CD pipelines as a common workflow/pipeline.

A group of resources or pipeline with such a workflow is often considered an environment - a group of services dedicated to this environment with some inter-dependency between them (for example: an S3 bucket with an SQS topic or perhaps some Lambda functions).

There are two common approaches here:

Dependencies

A pretty common approach by most CI/CD providers is to define which “job”, “run” or “stack” depends on other resources.

This allows us to create a fine grain dependency workflow.

Phases

Alternatively, in a simpler take on dependencies, jobs/runs/stacks are grouped by phases and deployed sequentially, but simultaneously inside each phase. Each phase starts after the previous phase completes.

How env0 Solves this

To set up an env0 Workflow follow this simple guide:

env0 relies on a file named env0.workflow.yml which describes the dependencies and configuration of the sub environments in your workflow. Create this file with your specific definitions, where each environment should define:

  1. name: This will be displayed in the workflow graph.
  2. templateName: A name of a pre-defined Template to deploy;
  3. needs (optional): An array of sub environments which all must be successfully deployed before this sub environment can start deploying.
environments:
vpc:
name: 'VPC and Network'
templateName: 'VPC'
db:
name: DB
templateName: 'DB'
needs:
- vpc
eks:
name: EKS
templateName: 'EKS'
needs:
- vpc
service1:
name: 'Billing Service'
templateName: 'Billing Service'
needs:
- db
- eks
service2:
name: 'Configuration Service'
templateName: 'Configuration Service'
needs:
- db
- eks
service3:
name: 'Notification Service'
templateName: 'Notification Service'
needs:
- db
- eks

‍

  1. Create a new Template and select env0 Workflow as the Template Type

In the VCS step fill in your VCS details and fill in the directory that contains your env0.workflow.yml file

  1. Create an Environment based on the Workflow template

a. Enable Drift Detection if so desired, using a cron expression based on the interval you would like to check the drift. For example, to check for drift twice a day at 8AM and at 8PM enter 00 08,20 * * *.

b. Select a Time-to-Live (TTL), with the ‌options‌:

Use “Unlimited” for a long running environment, “Destroy after x hours” for ephemeral environments, or “Specific time limit” for environments that have a predefined schedule.

c. Variables in env0 are inherited hierarchically from Organization -> Project -> Template -> Environment. This allows us to securely and easily reuse common variables, such as VPC IDs, API Keys, etc – while making it easy to have granular control over deployment specific variables.

  1. Deploy

As the resources are created, we can view our Workflow progress in the GRAPH tab.

Each sub-environment can be deployed individually. Workflows will also trickle down the rest of the dependencies.

By using env0 to manage workflows with dependencies, you’ll also get CI/CD, TTL/ephemeral environments, scheduling, drift detection, and deployment history out of the box.

Conclusion

Whether you’re using multiple infrastructure as code frameworks in your DevOps practice (Terraform, Terragrunt, Pulumi, CloudFormation, Kubernetes, etc) or asking “How do I manage the dependencies between infrastructure resources?”, env0 Workflows enable deploying many env0 Environments with complex dependencies as a ‌unit, using a simple YAML file.

Interested in learning more about env0?
Request a Demo
SHARE
You may also like
Recommendations for Migrating from Terraform Cloud
Infrastructure as Code is a Creative Job
How to integrate Azure DevOps with env0
Go back to blog
CNCF Member Badge
Company
About UsIn the NewsPress ReleasesCase StudiesAdditional ResourcesCareers
Developer and DevOps
APITerraform ProviderTerratag Open Source
Terraform Cloud AlternativeDIY AlternativeAtlantis Alternative
FREE TRIAL
Follow Us
Terms of ServicePrivacy PolicySecuritySystem Status
© Copyright env0 2023
This website uses cookies. We use cookies to ensure that we give you the best experience on our website. Learn More
PreferencesDenyAccept
Privacy Preference Center
When you visit websites, they may store or retrieve data in your browser. This storage is often necessary for the basic functionality of the website. The storage may be used for marketing, analytics, and personalization of the site, such as storing your preferences. Privacy is important to us, so you have the option of disabling certain types of storage that may not be necessary for the basic functioning of the website. Blocking categories may impact your experience on the website.
Reject all cookiesAllow all cookies
Manage Consent Preferences by Category
Essential
Always Active
These items are required to enable basic website functionality.
Marketing
These items are used to deliver advertising that is more relevant to you and your interests. They may also be used to limit the number of times you see an advertisement and measure the effectiveness of advertising campaigns. Advertising networks usually place them with the website operator’s permission.
Personalization
These items allow the website to remember choices you make (such as your user name, language, or the region you are in) and provide enhanced, more personal features. For example, a website may provide you with local weather reports or traffic news by storing data about your current location.
Analytics
These items help the website operator understand how its website performs, how visitors interact with the site, and whether there may be technical issues. This storage type usually doesn’t collect information that identifies a visitor.
Confirm my preferences and close