The CI/CD and DevOps Blog

Learn about various tried-and-tested strategies that will help you ship code faster

Provision AWS EC2 Virtual Machines With Terraform

This tutorial explains how to manually provision an AWS EC2 virtual machine using Terraform. Before you start, you should be familiar with the following concepts:

The best way to get started is to install Terraform and run scripts manually on your local machine to provision a VM. Once you understand the mechanics of it, you should consider automating your workflow by following our documentation on Automated provisioning of AWS EC2 using Terraform.

Provisioning AWS infrastructure with Terraform

Provisioning and updating infrastructure is a the first step in setting up your development, beta, or production environments. Hasicorp's Terraform format is fast becoming very popular for this use case.  We love Terraform at Shippable due to its easy declarative syntax, similar to our pipelines syntax. Other advantages are: 

  • Infrastructure as Code: Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used.

  • Execution Plans: Terraform has a "planning" step where it generates anexecution plan. The execution plan shows what Terraform will do when you call apply. This lets you avoid any surprises when Terraform manipulates infrastructure.

  • Resource Graph: Terraform builds a graph of all your resources, and parallelizes the creation and modification of any non-dependent resources. Because of this, Terraform builds infrastructure as efficiently as possible, and operators get insight into dependencies in their infrastructure.

  • Change Automation: Complex changesets can be applied to your infrastructure with minimal human interaction. With the previously mentioned execution plan and resource graph, you know exactly what Terraform will change and in what order, avoiding many possible human errors.

At Shippable, we use Terraform to provision all our environments and automate the provisioning using our Pipelines feature. If you're interested in taking a look at our terraform scripts and pipelines config, we have made our repositories public so you can check them out:  

Interested in trying it yourself? The following example walks you through a sample project that provisions two t2.micro instances on AWS. We've kept it simple for easy understanding, but you can also automate provisioning of complex environments as seen in our beta infra scripts above.

Infrastructure provisioning using Terraform

You can now provision infrastructure using Terraform through Shippable builds without having to worry about  merge conflicts in state files. If you aren't familiar with it, Terraform is a tool for building, changing and versioning infrastructure safely and efficiently. It can manage existing and popular service providers as well as  a part of a custom in-house solution. You can now use Terraform to provision your infrastructure in Shippable. Here's how to get started:

Setup a Container Cluster on AWS with Terraform Part 1-Provision a VPC

This post will be the first in a series of posts covering the basics of using Terraform to configure a container cluster on AWS and run a service on the cluster.  If you're not already familiar, Terraform is a pretty incredible open source tool from Hashicorp for configuring and launching infrastructure across a variety of providers.  By enabling you to manage your infrastructure provisioning and configuration as code (i.e. "Infrastructure as Code"), Terraform gives you repeatability and consistency, which you'll find tremendously useful when setting up complicated infrastructures, such as a container cluster and its underlying infrastructure on AWS.