Concept
Infrastructure as code (IaC)
Describing your infrastructure in files, so that a tool can build it the same way every time.
- 1You describe the environment once, in a template.
- 2CloudFormation builds an identical copy wherever you need one.
Step by step
- 1You describe the environment once, in a template.
- 2CloudFormation builds an identical copy wherever you need one.
The first build
- By hand in the console
- Quick: a few clicks
- Infrastructure as code
- Slower: you write the template first
Building it again
- By hand in the console
- Every step again, by hand
- Infrastructure as code
- Run the same template
Risk of mistakes
- By hand in the console
- Steps get missed or done differently
- Infrastructure as code
- Low: the same result every time
Tracking changes
- By hand in the console
- Hard to see what changed and why
- Infrastructure as code
- Every version is saved, reviewed and can be restored
Best for
- By hand in the console
- One-time tasks and learning
- Infrastructure as code
- Anything you will build or change again
| Compare | By hand in the console | Infrastructure as code |
|---|---|---|
| The first build | Quick: a few clicks | Slower: you write the template first |
| Building it again | Every step again, by hand | Run the same template |
| Risk of mistakes | Steps get missed or done differently | Low: the same result every time |
| Tracking changes | Hard to see what changed and why | Every version is saved, reviewed and can be restored |
| Best for | One-time tasks and learning | Anything you will build or change again |
1 / 3
The first build
- By hand in the console
- Quick: a few clicks
- Infrastructure as code
- Slower: you write the template first
Building it again
- By hand in the console
- Every step again, by hand
- Infrastructure as code
- Run the same template
| Compare | By hand in the console | Infrastructure as code |
|---|---|---|
| The first build | Quick: a few clicks | Slower: you write the template first |
| Building it again | Every step again, by hand | Run the same template |
2 / 3
Risk of mistakes
- By hand in the console
- Steps get missed or done differently
- Infrastructure as code
- Low: the same result every time
Tracking changes
- By hand in the console
- Hard to see what changed and why
- Infrastructure as code
- Every version is saved, reviewed and can be restored
| Compare | By hand in the console | Infrastructure as code |
|---|---|---|
| Risk of mistakes | Steps get missed or done differently | Low: the same result every time |
| Tracking changes | Hard to see what changed and why | Every version is saved, reviewed and can be restored |
3 / 3
Best for
- By hand in the console
- One-time tasks and learning
- Infrastructure as code
- Anything you will build or change again
| Compare | By hand in the console | Infrastructure as code |
|---|---|---|
| Best for | One-time tasks and learning | Anything you will build or change again |
What it is
Infrastructure as code means you describe the resources you need, such as a network, servers and a database, in a text file instead of creating them by hand. A tool reads the file, called a template, and builds everything for you. On AWS, the main tool for this is AWS CloudFormation.
Because the template is a file, you can keep it in version control, review a change before it is made, and go back to an earlier version. The same template builds identical environments for development, testing and production, or a copy in another Region for disaster recovery.
What it is
Writing a template takes more effort than a few clicks, so a one-time experiment is fine in the console. IaC pays off whenever you must build or change the same thing more than once. Developers can also define infrastructure in a programming language with the AWS Cloud Development Kit (AWS CDK), which deploys through CloudFormation.
Remember
- Repeatable: the same template builds the same environment every time.
- Fewer mistakes: no forgotten steps or typing errors.
- Changes are reviewed and versioned like application code, and can be rolled back.
- Fast recovery: rebuild a whole environment, even in another Region.
Remember
- On AWS, the main IaC service is AWS CloudFormation.
On the exam
- “Repeatable”, “consistent across environments” or “keep infrastructure in version control” points to infrastructure as code, with AWS CloudFormation.
- “A one-time task” or “try out a service” points to the console. IaC is for things you will do again.