chapter four

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

 

This chapter covers

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

To run a virtual machine, a lot of hardware and software is needed. Power supply, networking gear, host machine, operating system, virtualization layer, and much more. Luckily, AWS runs the hardware and software for us. Even better, we can control all of that with software. AWS provides an application programming interface (API) that we can use to control every part of AWS with HTTPS requests. In the end, you can write software that spins up VMs on AWS as well as in-memory caches, data warehouses, and much more.

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:

  • Command-line interface (CLI)—With one of the CLIs, you can make calls to the AWS API from your terminal.
  • Software development kit (SDK)—SDKs, available for most programming languages, make it easy to call the AWS API from your programming language of choice.
  • AWS CloudFormation—Templates are used to describe the state of the infrastructure. AWS CloudFormation translates these templates into API calls.

4.1 Using the command-line interface

4.1.1 Installing the CLI

4.1.2 Configuring the CLI

4.1.3 Using the CLI

4.1.4 Automating with the CLI

4.2 Programming with the SDK

4.2.1 Controlling virtual machines with SDK: nodecc

4.2.2 How nodecc creates a virtual machine

4.2.3 How nodecc lists virtual machines and shows virtual machine details

4.2.4 How nodecc terminates a virtual machine

4.3 Infrastructure as Code

4.3.1 Inventing an infrastructure language: JIML

4.4.1 Anatomy of a CloudFormation template