liveBook · Manning

Machine type

As explained in Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu

An instance type is a cloud virtual-machine specification that determines its available compute, memory, networking, and related capacity.

A machine type, also called an instance type, specifies an AWS virtual machine’s capabilities, including CPU and memory limits. Different workloads can require different types, so selecting the type should be part of the configuration rather than a hard-coded decision. section 3.8

Terraform makes machine-type selection operationally useful by exposing it as module configuration:

  • Declare an instance_type input variable with the string type, description, and an optional default. section 3.8.2
  • Pass var.instance_type to the aws_instance resource so callers can choose the machine without editing the module. section 3.8.2
  • Use a modest default such as t3.micro when cost-conscious testing is the priority, while allowing more powerful choices for other workloads. section 2.1.5 section 3.8

Selecting a machine type in a reusable module

A module can define instance_type as a string with a default of t3.micro, then assign it to the instance_type argument of aws_instance. A caller can override that value to launch a more capable machine while reusing the same module and subnet configuration.

How Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu covers it

How deep it goes
Defines CPU and memory implications and demonstrates Terraform variable wiring, but does not compare machine families or performance characteristics.
Examples
Demonstrates t3.micro as a testing default and shows a variable-driven aws_instance configuration.
What it assumes
Assumes basic Terraform resources and AWS instances, while teaching variable declarations and module customization.
What you can do after
Operate/configure Terraform modules by choosing an instance type without modifying their resource definitions.
How it connects
Connects machine types with AWS instances, Terraform input variables, modules, subnets, workloads, and infrastructure cost.

Also explained in

Compare how 2 books explain machine type →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu. The section links point to the parts of the book it draws on.