Codifying the Cloud with IBM Cloud Schematics

As everyone from startups to modern enterprises move applications into the cloud, the way we develop and deploy applications has changed dramatically. Gone are the days of shrink-wrapped software, installation scripts, and long product release cycles. Instead, the focus is on rapid, iterative development and automated deployment into cloud infrastructures.

Modern cloud infrastructure ranges from low level components such as bare metal servers, load balancers, firewalls, networks, and virtual machines (IaaS), to high level components such as containers, Cloud Foundry, Cloudant, OpenWhisk, and Watson services (PaaS).

Infrastructure as code (IaC) as defined by Wikipedia:

“The process of managing and provisioning computer data centers through machine-readable definition files, rather than physical hardware configuration or interactive configuration tools.”

IBM Cloud Schematics is an IaC automation tool that you can use to define and deploy your cloud resources as a single unit, and reuse those cloud definitions across any number of environments. Those cloud resources range from the traditional infrastructure to managed cloud service offerings. Schematics is available to all IBM Bluemix users through the Bluemix UI, command line interface (CLI), or RESTful API.

Schematic Configurations

Schematics uses Terraform to codify infrastructure. With Terraform, you can spin up numerous resources at the same time, as a collective group, with dependencies mapped within. Components of your infrastructure are broken down into individual resources, which can be anything from physical hardware to user accounts.

When you work with Schematics, you write configurations in a declarative syntax that state how you want to your cloud environment to ultimately look like. As the configuration changes the service adds and removed resources for you. Using a schematic is a three-step process:

The steps to start using a schematic

First, you select your schematic configuration from your library. Schematic configurations are meant to be shared and collaborated on. Configurations in your library could have been created by you, by IBM, an IBM business partner, or shared by another part of your organization.

Next, you create and review your plan. The environment plan has all the changes your configurations will make to your cloud infrastructure. It’s a best practice to always create a plan for review before applying the plan.

When you apply a plan, Schematics will provision and orchestrate your infrastructure. New cloud resources are created and existing resources are modified or deleted based on the configuration you are using. The thing to remember is that once you apply the plan, your resources are provisioned in the IBM Cloud and you can use your environment.

A Sample Schematic Configuration

Schematic configurations are simple text files using Terraform syntax that list the cloud resources you want to manage and the properties they are comprised from. You version control schematic configurations just like you version control your code.

For example, let’s say you have a custom web application that runs inside a virtual machine and uses a Redis database and Watson’s text-to-speech service. First, we need to provide our credentials to the IBM Cloud provider:

Defining the provider and credentials to use

The ${var.XYZ} interpolation in the snippet represent variables that you can supply values for from a file or in the IBM Cloud Schematics service. Using variables allows a configuration to be flexible and shared more readily.

Here’s a snippet for a virtual machine specification:

A sample schematic resource definition for a virtual machine

In the snippet, I hardcoded the values for various parameters of the virtual machine. A more flexible specification would use variables for some, or all, of these values. Our Redis database and Watson text-to-speech services are specified with resource definitions as well.

Resource definitions for Redis and Watson Text-to-Speech

As you can see, each resource type has a set of parameters you need to specify. The IBM Cloud Provider documentation tells you the exact set of parameters available for all of the IBM Cloud resources supported.

Schematic Environments

Schematic configurations are associated with environments. A Schematic environment is comprised of a pointer to configuration in source control, a name, and values for any required variables from your configuration, like your IBM Bluemix credentials, the data center you want to deploy to, etc.

Creating an environment is easy — you just enter in the source control url for your schematic and then fill in the required fields.

Once we have an environment, we can plan that environment and then apply it. The plan lists the set of changes to our cloud infrastructure and services and the apply action actually makes those changes.

When you apply a plan, what you’ll see is that after a little time, the activity log will show us that the plan has been applied successfully and your cloud resources have been created.

IBM Cloud Schematics Service

IBM Cloud Schematics is available to all Bluemix users. You can access Schematics from your Bluemix dashboard underneath the Services category in the main navigation. You can learn more about how to manage cloud environments and build enterprise-scale schematics in the “Getting Started” section of the IBM Cloud Schematics UI.

Schematics is also available via CLI and REST API for you to integrate with the rest of your toolchain. Everything that you can do from within the Bluemix console, you can do on the command line or through the REST API.

Schematics gives you a simple way to define and manage your cloud application infrastructure in a repeatable and automated fashion. Click here to log into IBM Bluemix and go right to IBM Cloud Schematics.