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 10, 2020

Making Continuous Deployment of Terraform code easier with env0

Arel Rabinowitz
Software Engineer

It seems like everyone on the web is moving to Continuous Deployment these days, and for good reason. With a Continuous Deployment flow in place, less time is spent worrying about releasing code, and more time is spent on creating new features or fixing bugs. The fast flow of delivery also helps with quick feedback from users, and the speed of delivering fixes when necessary.

While setting up your CD pipeline can seem complicated, with a new generation of tools it’s actually gotten a lot more simple. For this guide, I’ll show you how to set up an easy CD pipeline using env0, which provides an easy way of continuously deploying your Terraform code, with minimal effort. I’ll also be using GitHub to manage my sample code, which will be deployed on AWS.

In fact, this process is so simple, that there’s really just one step after you’ve completed your setup of env0. If you’d like to try it out for yourself, all you need is:

  • An env0 account (It’s free! Just join here)
  • A GitHub account
  • An AWS account

Let’s get to it

env0 Basic Setup

As a first step, I followed env0’s getting started guide to create my own organization, connect my AWS account, and create a template for my terraform code.

When creating the template, I also installed the env0 GitHub App, and allowed it to access my GitHub repository.


Triggering Deploys on New Commits

Now we just need to create an environment using the template we have created, and tell env0 to continuously deploy on push events to the git repo.

Simply go to the Project Templates page, and click “Run now” on the template that we’ve created. In the next screen you will need to do the following:

  1. Pick the branch you would like to continuously deploy, under the “Revision” field. I picked the master branch
  2. Check the “Redeploy on every push to the git branch” checkbox
  3. Click on “Run”

Your environment is now deploying! When it’s done, you can go to the “resources” tab to get the “website_endpoint” from our terraform code’s output, and check that our website is up and running.

And we’re done!

Welcome to the website

Now, let’s check if the environment will really deploy on push to master. Let’s create a Pull Request and add a new S3 bucket hosting another html file. We can accomplish this by:

  • Creating a `new.index.html` file, with the new content we want to host
  • Adding the following code to `main.tf`:
module “my_new_website” {  
 source = “./my-website-bucket”     
 name = “env0.my-new-website.cd.blog.com”  
 html_file_source = “new.index.html”
}
output “my_new_website_endpoint” {  
 value = module.my_new_website.website_endpoint
}

After we’re done, let’s merge the Pull Request and go to env0 and see the new deployment


Viola! Our terraform file changes were applied successfully, and a new S3 bucket was created hosting our new html file

Learn more

env0 is a complete environment-as-a-service solution. Our continuous deployment solution is only one way in which env0 lets you automate your Terraform code. Continuously deploying your code in env0 gives you tools to govern your environment. For example:

  • Complete history - env0 provides you with audit logs on each action that happened on your environment, both on manual and automated ones
  • Cost monitoring - view cost over time for your environment, and correlate how deployments affect the cost of your environment
  • Role based access - Managing your environments through env0 allows you to have full control over who has permissions to plan/apply your terraform code

You’re welcome to check out our docs about continuous deployment, or if you’d like, just reach out or schedule a demo with us!


Interested in learning more about env0?
Request a Demo
SHARE
You may also like
Day 0 Environment Creation
Share outputs between IaC stacks
Chris' Corner - March 2023
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