Chapter 4. Programming your infrastructure: The command-line, SDKs, and CloudFormation

 

This chapter covers

  • Understanding the idea of infrastructure as code
  • Using the CLI to start a virtual machine
  • Using the JavaScript SDK for Node.js to start a virtual machine
  • Using CloudFormation to start a virtual machine

Imagine that you want to provide room lighting as a service. To switch off the lights in a room using software, you need a hardware device like a relay connected to the light circuit. This hardware device must have some kind of interface that lets you send commands via software. With a relay and an interface, you can offer room lighting as a service.

This also applies to providing VMs as a service. VMs are software, but if you want to be able to start them remotely, you still need hardware that can handle and fulfill your request. AWS provides an application programming interface (API) that can control every part of AWS over HTTP. Calling the HTTP API is very low-level and requires a lot of repetitive work, like authentication, data (de)serialization, and so on. That’s why AWS offers tools on top of the HTTP API that are easier to use. Those tools are:

4.1. Infrastructure as Code

4.2. Using the command-line interface

4.3. Programming with the SDK

4.4. Using a blueprint to start a virtual machine

Summary