Using Terraform in AWS Mumbai

Terraform is a fantastic tool to manage your infrastructure with simple and declarative templates; you simply describe your infrastructure in a template file that looks like:

1
2
3
4
5
6
7
8
9
10
11
12
13
resource "digitalocean_droplet" "web" {
    name = "tf-web"
    size = "512mb"
    image = "centos-5-8-x32"
    region = "sfo1"
}

resource "dnsimple_record" "hello" {
    domain = "example.com"
    name = "test"
    value = "${digitalocean_droplet.web.ipv4_address}"
    type = "A"
}

run terraform apply and you’re set: Terraform will boot the infrastructure for you.

AWS recently launched their ap-south-1 region (Mumbai, India) and, due to the fact that’s much closer to our customer and EC2 there seems to be ~10% cheaper than in AWS Singapore (where we’re currently hosted), we wanted to start experiment moving part of our infrastructure to this region.

Terraform, though, has an hardcoded list of AWS regions and, since Mumbai is a recent addition, it will throw an error saying that the region isn’t supported.

The guys have already added the new region in master, so we could just wait for the next stable release to be rolled out and we’ll be able to rock it in Mumbai but, since we’re troublemakers, let’s just not wait and figure a way to boot our machines in Mumbai now :)

Since the changes are already in master, we just need to clone the terraform repo and build it locally:

1
2
3
git clone [email protected]:hashicorp/terraform.git
cd terraform
TF_DEV=1 ./scripts/build.sh

That’s it — a new terraform executable will be created with the latest code from master (if you’re wondering, the TF_DEV variable makes it so we build terraform only for our architecture, else the build.sh script will also build for bsd, darwin, etc).

Nothing more, nothing less :) Have fun booting your infrastucture with Terraform: it’s an amazing tool built by a great company in the DevOps landscape.


Hi there! I recently wrote an ebook on web application security, currently sold on leanpub, the Amazon Kindle store and gumroad.

It contains 160+ pages of content dedicated to securing web applications and improving your security awareness when building web apps, with chapters ranging from explaining how to secure HTTP cookies with the right flags to understanding why it is important to consider joining a bug bounty program.

Feel free to skim through some of the free chapters published on this blog and, if the content seems interesting enough to you, grab a copy on leanpub, the Amazon Kindle store, gumroad or simply checkout right down below!

Buy the Web Application Security ebook for $9.99

In the mood for some more reading?

...or check the archives.