Making Continuous Deployment of Terraform code easier with env0

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:
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.
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:
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!
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:
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
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:
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!