🎉 Announcing new lower pricing — up to 40% lower costs for Cloud Servers and Cloud SQL! Read more →

Terraforming Brightbox

Today we’re announcing Brightbox support for Hashicorp’s Terraform in the form of a new provider plugin.

Terraform is a tool to make managing your overall system infrastructure as easy as managing your individual server configuration. You map out all the different components of your systems from as many different providers as you need and represent them all in code. Terraform handles working out all the dependencies, building the components and configuring all the relationships.

It’s focused very much on infrastructure, so once everything is built the baton is passed onto your configuration management tool of choice, such as Puppet, Chef or Ansible. Terraform just handles orchestrating the bootstrapping.

The result is an executable description of all the infrastructure you need to build your entire system from scratch.

Example

A simple example to start with. This defines a cloud server and a cloud MySQL database instance, Cloud IPs for them both and a group for the server. It handles mapping the Cloud IPs and granting the cloud server access to MySQL:

resource "brightbox_cloudip" "webip" {
  target = "${brightbox_server.webserver.interface}"
  name = "web ip"
}

resource "brightbox_server" "webserver" {
  image = "img-hp57r"
  name = "web server"
  server_groups = ["${brightbox_server_group.webservers.id}"]
}

resource "brightbox_server_group" "webservers" {
  name = "web servers"
}

resource "brightbox_cloudip" "db" {
  target = "${brightbox_database_server.db.id}"
  name = "db ip"
}

resource "brightbox_database_server" "db" {
  name = "db server"
  database_engine = "mysql"
  database_version = "5.6"
  maintenance_weekday = 6
  maintenance_hour = 2
  allow_access = ["${brightbox_server_group.webservers.id}"]
}

Apply it

And then actually applying it using the terraform cli tool makes it all happen:

$ terraform apply

brightbox_server_group.webservers: Creating...
brightbox_server_group.webservers: Creation complete
brightbox_server.webserver: Creating...
  server_groups.3081397718: "" => "grp-ymx9v"
brightbox_database_server.db: Creating...
  allow_access.3081397718: "" => "grp-ymx9v"
brightbox_server.webserver: Creation complete
brightbox_cloudip.webip: Creating...
  target:      "" => "srv-cz95i"
brightbox_cloudip.webip: Creation complete
brightbox_database_server.db: Creation complete
brightbox_cloudip.db: Creating...
  target:      "" => "dbs-slg0b"
brightbox_cloudip.db: Creation complete

Apply complete! Resources: 5 added, 0 changed, 0 destroyed.

Outputs:

  db admin account password = 14rviz1sf36d6xk5
  db ip address             = cip-ktf1w.gb1.brightbox.com
  web public ip address     = cip-crl7w.gb1.brightbox.com

Terraform keeps track of what resources it created in a local state file so you can make changes to the config and and it’ll just apply what needs to changed.

Destroy it

And when you’re done, you can tell it to destroy everything it created too:

$ terraform destroy

brightbox_server_group.webservers: Refreshing state... (ID: grp-ymx9v)
brightbox_server.webserver: Refreshing state... (ID: srv-cz95i)
brightbox_database_server.db: Refreshing state... (ID: dbs-slg0b)
brightbox_cloudip.webip: Refreshing state... (ID: cip-crl7w)
brightbox_cloudip.db: Refreshing state... (ID: cip-ktf1w)
brightbox_cloudip.webip: Destroying...
brightbox_cloudip.db: Destroying...
brightbox_cloudip.webip: Destruction complete
brightbox_server.webserver: Destroying...
brightbox_cloudip.db: Destruction complete
brightbox_database_server.db: Destroying...
brightbox_server.webserver: Destruction complete
brightbox_database_server.db: Destruction complete
brightbox_server_group.webservers: Destroying...
brightbox_server_group.webservers: Destruction complete

Apply complete! Resources: 0 added, 0 changed, 5 destroyed.

Other resources

Our Terrform provider also includes support for managing cloud load balancers, Orbit object storage containers and firewall policies. Everything you to manage your Brightbox infrastructure.

Other providers

Terraform can manage resources across multiple providers at the same time, so you could, for example, use the DNSMadeEasy provider to create DNS records for the new cluster, or use the Docker provider to setup some containers on it.

Get started

We’ve got a detailed guide on getting Terraform installed and building your first cluster on Brightbox Cloud.

You can sign up for Brightbox in just a couple of minutes and get a £50 free credit to play with Terraform.

Get started with Brightbox Sign up takes just two minutes...