Skip to content

Latest commit

 

History

History
 
 

012-InfraAsCode-Terraform

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

What the Hack: Infrastructure as Code with Terraform

Introduction

DevOps is a journey not a destination. Implementing Infrastructure-as-Code is one of the first steps you will take on your DevOps journey!

When implementing an application environment in the cloud, it is important to have a repeatable way to deploy the underlying infrastructure components as well as your software into the target environment. This includes resources such as:

  • Virtual Networks, Network Security Groups (Firewalls), Public IPs, Virtual Machines, Storage (Disks)
  • PaaS Services (Azure SQL, App Service, etc)
  • Configuration Management (installing & configuring software on VMs)

The best way to make deployments repeatable is to define them with code, hence the term "Infrastructure as Code" (aka IAC). There are multiple technologies that enable you to define your IaC. Some of these include:

  • Azure Resource Manager (ARM) Templates
  • PowerShell Desired State Configuration (DSC)
  • HashiCorp's Terraform & Packer
  • Ansible, Chef, Puppet, Salt Stack, and others

Terraform is a tool (templating language) for building, changing, and versioning infrastructure safely and efficiently. Using Terraform, you can automate the tasks of building, changing and de-provisioning the infrastructure

This hack is focused on using Terraform to implement your IaC. It does not mean this is the only way to implement IaC. It is just one way amongst many. If you want to learn how to do IaC in Azure with other technologies, try one of our other IaC hacks for ARM Templates or Ansible.

Learning Objectives

This hack will help you learn:

  • How Terraform works to deploy infrastructure in Azure
  • How Terraform can be used to trigger the install of software on a VM

Challenges

  1. Get your machine ready
    • Configure Terraform on Linux subsystem, credentials
  2. "Hello World" Terraform
    • Create an Azure resource group using Terraform
  3. Deploy a Virtual Network
    • Learn how to find Terraform HCL syntax to deploy an Azure resource
  4. Open Some Ports
    • Learn about variables, dependencies, idempotency
  5. Create a Linux Virtual Machine
    • Learn what an Azure Virtual Machine is composed of
  6. Use Packer to Create a Linux image with NGINX installed
    • Learn about custom build images with Packer

Prerequisites

  • Your own Azure subscription with Owner access
  • Visual Studio Code
  • Azure CLI
  • Terraform

Repository Contents

  • ../Coach/Solutions
    • Complete solution files for each challenge
  • ../Student
    • Terraform challenges

Contributors

  • Pete Rodriguez