Lesson 3 of 4 · Introduction to Terraform

Providers and resources

A provider is Terraform’s connection to a platform, such as AWS, Azure, Google Cloud, or a service outside the major clouds. A resource is one thing you want that provider to manage. Each provider supplies its own resource types, but the Terraform structure stays familiar: a type and a local name form an address.

Example

# This is an AWS example. Other providers use the same pattern.
provider "aws" {
  region = "us-east-1"
}

resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
}

Step by step

  1. Choose the provider for the platform you are using.
  2. Configure that provider, for example with a region or project.
  3. Add a resource block.
  4. Give the resource a descriptive local name and use its address elsewhere.

Common mistakes to avoid

  • Misspelling a resource type, for example aws_instnace instead of aws_instance.
  • Assuming a cloud-console feature has exactly the same name in Terraform.