Terraform's whole job is creating these things, so you need a clear picture of them before writing a single line.
Every website and app runs on computers somewhere. You already know a server: a computer that is always on and reachable over the internet. Companies used to buy their own and keep them in a back room. Today most rent them from a cloud , a company such as Amazon Web Services (AWS), Microsoft Azure or Google Cloud that owns huge buildings full of computers and rents out pieces of them by the hour.
Renting computing this way is called the cloud. A rented server is usually a virtual machine: a complete computer simulated in software, one of many sharing a real machine. You can have one running in a minute and delete it when you're done.
The things you rent are called resources, and together they make up your infrastructure: the foundation your app stands on, like the plumbing and wiring of a building.
Common resources:
- virtual machines, to run programs;
- storage buckets: online folders for files, such as photos your users upload;
- databases: organised stores of data, such as customer accounts;
- private networks that connect your machines and keep strangers out;
- user accounts and permissions saying who may do what.
Websites also need DNS records. DNS is the internet's address book: it turns a name like shop.example.com into the numeric address of your server.
Each cloud provider runs its machines in several regions, groups of buildings in one part of the world, such as Ireland (eu-west-1) or Virginia (us-east-1). You pick regions close to your users.
There are two ways to create resources. People click through the cloud company's web console, a website for managing the account. Programs use its API: a fixed menu of instructions a program can send, like "create a bucket named photos", which the company's computers then carry out.
Every instruction must prove who sent it. The cloud company gives you credentials, such as an access key (a long secret password meant for programs), and only accepts instructions that carry valid ones. Guard them like house keys: anyone holding them can create, change or delete what you rent, and you get the bill.
Remember
- A cloud provider rents out servers, storage, databases and networks by the hour
- The things you rent are resources; together they are your infrastructure
- Programs create resources through the cloud provider's API, using secret credentials
Watch out for
- Sharing or committing cloud credentials: anyone holding them can use your account and run up charges.
New words in this lesson
- provider
- A Terraform add-on program that knows one service, such as AWS or GitHub, and turns Terraform's requests into that service's API calls. Learn it →