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
Sep 9, 2021

Manual Approval Workflow using env0’s Custom Flow and API

Andrew Way
Director of Sales Engineering

You like env0 because it can automate your IaC deployment process, but you also like your existing manual approval workflow through Jira or ServiceNow. With env0’s custom flow and API, we can easily integrate your manual approval workflow with env0’s IaC deployment workflow. This blog will show an example of approving the env0 deployment through your ticketing system.

In order to simplify this blog, we’ll start with a very simple ticketing system built on top of Zapier (note: Zapier Subscription with Premium apps is required).  

Code example can be found here.

First in Zapier, we’ll create a flow (use this link to make a copy) composed of two webhook stages and an approval stage. The first webhook stage will be our receiver, the endpoint which our custom flow will call in order to notify that a plan is complete.

We will also need to create an API key for Zapier to call env0 APIs. To create an API key, see our API reference docs. The API key will be used by the Webhook PUT action at the end of our Zapier workflow.

The API we’ll be using is the Resume Deployment endpoint. It takes the deployment ID as part of the path.
‍

https://api.env0.com/environments/deployments/$ENV0_DEPLOYMENT_LOG_ID

This completes our Zapier setup. Next, we need to add a custom flow.

CUSTOM FLOW

The env0 Custom Flow allows us to add custom scripts at various stages of the deployment workflow. You can read more about it here.

In your env0 template, we will add a Custom Flow env0.yml, that will call the Zapier webhook after the Terraform Plan stage. The most important piece of information we need to send is the deployment ID. This will be used later after the manual approval process to resume (and approve) the deployment through the env0 API. Luckily for us, the deployment ID is easily referenced through the environment variable ENV0_DEPLOYMENT_LOG_ID.  Also, we are going to use an additional environment variable $ZAP_HOOK so that we can dynamically configure the endpoint in env0’s UI.

env0.yml
```yaml

version: 1
deploy:
 steps:
   terraformPlan:
     after:
       - echo "Request external approval"
       - curl --location --header "Content-Type:application/json" --request POST "$ZAP_HOOK" -d "{\"deployment\":\"$ENV0_DEPLOYMENT_LOG_ID\"}"
       - echo "To approve, visit https://tables.zapier.com/approval/inbox/id/3784"
```

We now have a 3rd party Manual Approval workflow system that can easily be adapted to your ticketing system. Check out this short gif of this Custom Flow in action.

‍


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