Terraform Certified

Tags: DevOps

Learn Terraform Using Docker, AWS, Kubernetes, and more!

Last updated 2022-01-10 | 4.6

- Terraform
- Infrastructure as Code
- Docker

What you'll learn

Terraform
Infrastructure as Code
Docker
AWS
Devops
Hashicorp Configuration Language
Terraform Cloud

* Requirements

* Linux Command Line
* Basic Understanding of AWS and Docker is Useful

Description

This course will teach you what you need to know to deploy Terraform resources properly and efficiently whether you're a beginner or someone looking for some new tricks! We will start with the very basics and methodically build from there, learning new information, tricks, and skills along the way! Most lessons are less than 8 minutes long to help ensure a pace that doesn't put you to sleep! 

With a focus on using built-in tools to deploy and troubleshoot your deployments, you'll be the only one not having to Google every error you find or copy and paste from Stack Overflow! 

You'll learn important Terraform tools to troubleshoot and build your infrastructure as you roll out a Node-RED IoT application using Docker, a Rancher K3s Kubernetes deployment on AWS, a Kubernetes deployment of pods, and even a full CICD deployment using Terraform Cloud!

We'll focus on writing efficient code with minimal repetition while utilizing many of Terraform's advanced features such as:

  • Import       

  • Join

  • Min

  • Max

  • Local Resource

  • Variables

  • Splat

  • For Loops

  • Dynamic Blocks

  • Variable Validation

  • Path References

  • String Interpolation

  • Workspaces

  • Local and Remote Provisioners

  • and more! 


The entire course was recorded using quality equipment for ease of listening, intelligent zooming and cursor highlighting to ensure maximum readability and the ability to follow along easily, and annotations where necessary to quickly see web links to visit, important topics, and follow along with the resources more easily.

All of the code is tested using the 0.14+ version of Terraform and new updates will always be tested and rolled out as soon as possible! 


So what are you waiting for? Sign up today and Terraform Apply Yourself!


Who this course is for:

  • Devops Engineers
  • Cloud Engineers
  • IT
  • Support

Course content

6 sections • 133 lectures

Introduction to the Course Preview 02:29

Terraform Version Notes (Important!) Preview 01:21

Downloading the Code Preview 00:15

AWS Setup and Cloud9 Info Preview 00:22

New AWS Account Setup Preview 05:24

Configuring Billing Alarms Preview 03:12

Adding Security to your AWS Account Preview 05:32

In this lesson, we'll add security to your AWS Account. Please note, we will utilize the security measures recommended by AWS, but if you are using a corporate or enterprise account, be sure to consult your security advisors first to ensure compliance.


https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html

AWS Cloud9 Configuration Preview 04:05

AWS Cloud9 Disk Expanding Preview 03:44

In this lesson, we're going to expand the disk space on our Cloud9 instance to ensure we have enough room to store our resources.

Security Groups and IP Access Preview 02:22

In this lesson, we're going to configure our AWS Security Group rules to allow access to our instance from our workstations. This will allow us to see the applications we deploy in our browser. Please note, if you are in a corporate account or using a corporate account, please verify with your security team that this is ok! 

Terraform Installation (Same Instructions for all Versions) Preview 03:05

In this lesson, we install Terraform. Please note that I will be using Apt since it is compatible with the Ubuntu distribution we are using. If you are using another distribution, you can find installation instructions here: 

https://learn.hashicorp.com/tutorials/terraform/install-cli

Terraform Terminology (Skip if you have passed the exam or are already familiar) Preview 08:06

In this lesson, I'm going to cover the basics of Terraform, some of the terminology you're going to see, and some differences between it and other utilities such as Cloudformation and Ansible. Now, this is the first and only lesson that is mostly a Powerpoint slideshow, so please bear with me. If you are pretty comfortable with what Terraform is, idempotence, declarative vs. imperative programming, etc., then you can probably skip this and head straight to the fun stuff! 

Docker Provider Upgrade Notice! (Important!) Preview 00:34

The Docker Provider Preview 04:45

We will configure our Docker Provider in this lesson to get our deployment setup!

Terraform Init Deeper Dive Preview 03:25

In this lesson, we'll dive a little deeper into what happens when Terraform Init is run.

Terraform Dependency Lock (v0.14+ only) Preview 06:40

In this lesson, we're going to discuss one of the most important changes to Terraform 0.14. *Note* You may notice some lessons after this do not match this syntax as the changes weren't breaking changes, I didn't want to delay the entire course to modify a few lines.

Your First Terraform Apply! Preview 06:19

In this lesson, we'll finally deploy an actual resource!

Terraform Plan and Apply Deeper Dive Preview 05:33

We'll cover a little more about the Terraform Apply command here.

Referencing other Resources Preview 06:30

In this lesson, we'll see how to reference another resource to provide information required to deploy.

Viewing Your Deployment in the Browser Preview 03:13

In this lesson, we'll finally take a look at an early version of our deployment!

Terraform State Deeper Dive Preview 07:24

Time to take a little bit of a deeper look into the state.

Terraform Console and Outputs Preview 07:49

Being able to access and see metadata about our infrastructure is crucial to a successful Terraform Deployment.

The Join Function Preview 06:37

The Random Resource Preview 09:16

Utilizing Random strings, IDs, and more is tantamount to ensuring a DRY and idempotent deployment.

Multiple Resources and Count Preview 07:28

Using the Count parameter in Terraform is crucial to scaling resources and maintaining a DRY configuration.

The Splat Expression Preview 05:04

Using the Splat Expression allows you to access all resources deployed using the count parameter.

"For" Loops Preview 10:20

Using For Expressions can provide a more granular approach that the Splat Expression sometimes does not allow.

Tainting and Updating Resources Preview 05:32

The Taint command can become very useful when you need to reload a resource to apply a new configuration or otherwise reload it.

State Locking and Breaking State Preview 05:39

In this lesson, we break our state...on purpose! This will help illustrate the issues you may encounter during multi-engineer Terraform deployments.

Terraform Import Preview 09:59

In this lesson, we'll learn how to overcome a corrupted state by importing the extraneous resources.

Terraform Refresh and State rm (Updated!) Preview 08:15

Sometimes, you don't need to import extra resources, you just need them removed. With the refresh and state rm commands, this can be done easily and relatively safely.

Adding Variables Preview 07:29

We finally learn about variables here!

Variable Validation (v 0.13+ only) Preview 04:48

We investigate a relatively new feature for Terraform called Custom Validation to validate our variables.

Variables and Output Files Preview 02:48

In this lesson, we move our Variables and Outputs to external files in order to clean up our deployment.

Sensitive Variables and .tfvars files Preview 03:09

Not all variables can be committed to source control! That's why we need the tfvars files!

Variable Definition Precedence Preview 05:09

In this lesson, we'll take a look at how many organizations manage their variables using multiple .tfvars files. We'll then take a quick look at what happens when multiple variable definitions are presented to the deployment.

Hiding Sensitive Variables from CLI (v 0.14+ only) Preview 04:54

In this lesson, we work with a feature only available in Terraform 0.14. If you don't have it, you will need to upgrade your terraform installation. This feature will allow us to hide our sensitive variable definitions from the CLI in order to keep the terminal clean of any sensitive information.

The Bind Mount and Local-Exec Preview 11:04

We now get to add the volume required to use our node-red deployment! After this lesson, you'll be able to reload your containers and maintain the information stored in node-red.

Utilizing Local Values Preview 07:46

In this lesson, we'll cover another way to centralize our functions and data source: Local Values.

Min and Max Functions and the Expand Expression Preview 05:23

We'll cover Min and Max functions and the Expansion Expression (also known as the "spread operator" in other languages) in order to correct our variable validations.

Path References and String Interpolation Preview 03:58

In this lesson, we'll make our script more resilient to directory changes by referencing the local path instead of hardcoding our path. We'll also introduce a very useful feature called String Interpolation.

Maps and Lookups: the Image Variable Preview 07:24

In this lesson, we're going to utilize maps and the lookup function to enable us to deploy different versions of our infrastructure based on whether we set var.env to be "dev" or "prod".

Maps and Lookups: External Ports Preview 07:10

In this lesson, we continue our refactor to be able to specify different port ranges for different environments using the lookup function.

Terraform Workspaces Preview 05:49

Terraform Workspaces are incredibly important when deploying multiple environments, such as dev and prod. By utilizing workspaces, you can add another element of control to your deployments without introducing extra complexity.

Referencing your Workspaces Preview 04:59

Now that we're using workspaces, it's imperative that we know how to reference them and utilize them in our scripts. This will make things a lot easier and more efficient!

Utilizing Map Keys instead of Lookups Preview 03:40

Although the lookup function is very useful, it really is more clutter than we need. By referencing our maps using keys, we can clean up a lot of the clutter and make our scripts more efficient. But, lookups still has a purpose, and it has to do with setting defaults.

Terraform Basics Lab: Part 1

In this lab, you will deploy resources using Terraform and answer questions regarding the deployment to allow you to apply what you've learned. Ensure you do not delete the files you create as they will be needed for part 2!

Terraform Basics Lab 2

Use the code from the previous lab to answer more questions about the deployment.

Modules Intro Preview 02:28

In this lesson, we're going to take a quick look at what to expect in the upcoming lessons along with a brief overview of modules. For a deeper dive into the module information flow concepts, check out the "Module Information Flow" video a few lectures down.

First Module! Preview 08:54

In this lesson, we're going to deploy our first module!

Module Variables Preview 04:45

In this lesson, we will learn how to pass variables between modules and the root resources.

Terraform Graph Preview 07:57

In this lesson, we're going to see how Terraform Graph can be one of the most useful debugging and troubleshooting tools in our Terraform arsenal.

Troubleshooting Dependencies Preview 09:14

In this lesson, we're going to see a dependency issue and troubleshoot it using Terraform graph.

The Container Module Preview 11:16

In this lesson, we're going to deploy our container module and learn some design patterns along the way.

Module Outputs Preview 06:17

In this lesson, we're going to modify our outputs to support our new containerized infrastructure.

Module Information Flow Preview 05:47

In this lesson, we're going to reinforce what we've learned with a graphical representation of how information flows within modules. There is no code in this one, so sit back and enjoy as I illustrate how a variable becomes an output.

Docker Volume Preview 09:16

In this lesson, we're going to deploy our Docker Volume properly and see how different deployment strategies can behave in different ways.

Lifecycle Customization and Targeting Preview 05:05

In this lesson, we'll learn how to modify resources to prevent destruction or other customized behavior, then learn how to override that behavior using targeting.

One Module for Multiple Resources Preview 07:02

In this lesson, we'll see how to utilize one module for multiple resources.

Using for_each Preview 07:39

In this lesson, we're going to utilize Terraform's for_each syntax to make our code even more efficient.

Deploying Containers with for_each Preview 09:44

We're going to utilize for_each to deploy our containers.

Using Count and for_each Together Preview 09:15

In this lesson, we're going to utilize count and for_each together to allow us to deploy multiple volumes for multiple containers.

New Outputs and Map Transformations Preview 05:08

Time to learn more neat syntax to make our outputs even cleaner.

Grafana Apply Yourself! Preview 01:19

Time to put your knowledge to the test and use a lot of what we've learned to deploy another container!

Grafana Solution Preview 02:44

How did you do? Watch this video to find out!

Self Referencing and Provisioner Failure Modes Preview 07:17

In this lesson, we're going to take a look at how to reference resources within a provisioner by utilizing the "Self" object. We're also going to look into how to manage the failure behavior of a command to control the success of the deployment based on that command's success.

Terraform Apply Yourself - Self Referencing Preview 04:20

In this lesson, you're going to Terraform Apply Yourself and create a couple more provisioners to perform some cool new features!

Dynamic Blocks Preview 11:05

In this lesson, we're going to utilize Dynamic Blocks to enable us to dynamically specify the number of volumes required for each container without having to utilize an arbitrary "count" variable.

Nesting the Volume Module Preview 12:16

In this lesson, we're going to perform our most exciting feat yet! We're going to alleviate an issue with utilizing our Dynamic Blocks with Count. Currently, when we use Count with our containers, the volumes are only created based on that count and do not take into account the number of volumes required per container. By nesting the Volume module, we create exactly the right number of volumes per container based on the count. So if we have 5 Grafana containers and each container requires 2 volumes, we'll get 2 correct volumes for each container. If the InfluxDB container only requires one volume, but has a count of 5, it will get the 5 volumes it needs without any extra volumes lying around. After this lesson, you will have a truly scalable deployment! 

Weather Dashboard Project! Preview 12:35

We've finally made it! The end of the Docker sections of the course. And now it's time to actually use those containers we've been deploying for several hours! We're going to deploy a "space launch weather dashboard" by using Node-Red to pull data from the openweathermap.org API, add that data to an InfluxDB bucket, which Grafana will visualize in realtime!

The files needed are in the course resources and are as follows:
1. nodered-flow.json

2. grafana-dashboard.json

What We're Going to Build Preview 03:19

In this lesson, we're going to do a quick overview of what we're going to deploy in the AWS section!

Configuring Terraform Cloud Preview 05:56

In this lesson, we're going to setup and configure Terraform Cloud to host our state so we don't have to manage it ourselves. This will allow easy access to our state and the ability to lock/unlock at will.

The AWS Provider Preview 03:56

In this lesson, we will setup the AWS Provider in order to start deploying AWS resources!

Deploy a VPC Preview 10:29

Finally! We will deploy our first AWS resource: the VPC!

Remote State in Terraform Cloud Preview 03:17

Let's take a look at what exactly the Terraform Cloud is providing us.

VPC Subnets "Hardcoded" Preview 08:55

We're going to deploy some subnets in this lesson. We'll start easy by hardcoding them so we get a handle on how they are deployed.

VPC Subnets - Terraform Apply Yourself! Preview 04:02

Time to deploy some subnets yourself!

The cidrsubnet() Function Preview 08:54

In this lesson, we'll utilize the cidrsubnet() function to dynamically create subnets based on the count and conditions we specify.

The aws_availability_zones Data Source Preview 03:56

In this lesson, we'll utilize the aws_availability_zones data source in order to access on the available AZs for our region.

The random_shuffle Resource Preview 04:54

In this lesson, we'll use the random_shuffle resource to provide unlimited Availability Zones to use with our Subnets.

Why didn't we use for_each? Preview 01:16

Route Tables and the Internet Gateway Preview 10:11

Let's deploy our Route Tables and Internet Gateway so our resources can get to the internet.

The create_before_destroy Lifecycle Meta Argument Preview 04:51

Woops! Looks like the VPC is having issues with changes. Let's use the create_before_destroy Lifecycle Meta Argument to remedy that!

VPC Security Groups "Hardcoded" Preview 08:50

In this lesson, we're going to deploy a security group using hardcoded values to get a feel for its deployment. Don't worry, we'll refactor it to be dynamic afterwards!

VPC Security Groups Dynamic Preview 07:04

In this lesson, we're going to refactor our Security Groups to deploy them dynamically with for_each and dynamic blocks! 

VPC Security Groups - Terraform Apply Yourself! Preview 04:18

In this lesson, we're going to apply what we've learned and create another ingress rule and another security group dynamically!

VPC RDS Subnet Group and Conditionals Preview 06:56

In this lesson, we'll demonstrate how to use count and a conditional to specify whether a resource should exist or not in a deployment.

Basic RDS Setup Preview 07:11

In this lesson, we're going to deploy an RDS instance using hardcoded values to start.

VPC Outputs for RDS - Terraform Apply Yourself! Preview 05:38

In this lesson, you're going to Terraform Apply Yourself and create the necessary outputs from our VPC to deploy our RDS instance.

Managing Sensitive RDS Values Preview 05:37

In this lesson, we're going to utilize the sensitive attribute to obscure certain variables from our output as well as adding them to our terraform.tfvars file so they are not committed to our repos.

The Terraform Providers Schema Command Preview 03:53

In this lesson, we're going to utilize the terraform providers schema command to investigate the AWS provider components and view the new sensitive values change.

ALB Initial Setup Preview 05:41

In this lesson, we're going to begin scaffolding our Application Load Balancer

ALB Security Group and Subnets - Terraform Apply Yourself! Preview 03:42

In this lesson, you're going to Terraform Apply Yourself! and extract the resources you need for the load balancer from the networking module. You will utilize what you've learned about outputs and variables! 

ALB Target Group and the uuid and substr functions Preview 08:25

In this lesson, we're going to deploy the ALB Target Group. We'll be doing this with the help of the substr and uuid functions!

ALB Listener Preview 05:58

In this lesson, we're going to deploy the ALB listener that will listen for incoming traffic to the LB for forwarding.

Upgrading Terraform (0.14.1+ required for ignore_changes) Preview 00:14

ALB Lifecycle Policies: ignore_changes and create_before_destroy Preview 08:43

In this lesson, we're going to investigate some "wonky" behavior that causes the target group to be destroyed and redeployed every time we try to apply. We will also see why our destroy sequence ends up getting "hung" and not deploying properly without the create_before_destroy policy.

The aws_ami Data Source Preview 05:49

In this lesson, we're going to setup the aws_ami data source so we can reliably acquire the AMI ID needed for our EC2 instances.

Scaffolding Our EC2 Instance and random_id Preview 07:04

In this lesson, we're going to lay the groundwork for the deployment of our EC2 Instances.

EC2 - Terraform Apply Yourself! Preview 03:30

In this lesson, you're going to use your Terraform skills to populate the variables for the EC2 deployment!

SSH Key for Our Instance and the file Function Preview 06:27

In this lesson, we're going to use the file function to read in our SSH public key and deploy it to our EC2 Instance.

Controlling random_id Changes with Keepers Preview 04:09

In this lesson, we're going to use "keepers" to manage the change behavior of our random_id.

Userdata UPDATE! VERY IMPORTANT! Preview 00:14

EC2 User Data and Template Files Preview 06:49

In this lesson, we'll use the templatefile function to generate dynamic userdata for our instances.

EC2 User Data Template Variables - Terraform Apply Yourself! Preview 07:25

In this lesson, you are going to utilize your Terraform skills to populate the variables required for the template file used for our userdata.

Deploying NGINX to Our Kubernetes Cluster! Preview 06:53

In this lesson, we're finally going to deploy something to our brand new K3s Kubernetes cluster!

Adding our EC2 Instances to the Target Group Preview 07:45

In this lesson, we're going to add our instances to the load balancer Target Group in order for the Application Load Balancer to forward traffic to them.

Adding some Outputs for our Resources Preview 03:32

In this lesson, we're going to add some outputs to improve our deployment.

Sensitive Outputs and How to Access Them Preview 05:50

In this lesson, we're going to use the jq command to access sensitive resources in our deployment.

Terraform Apply Yourself - Outputs! Preview 04:23

In this lesson, you're going to deploy some outputs on your own! 

Utilizing the local-exec Provisioner to SCP our Kubeconfig File Preview 11:50

In this lesson, we'll use the local-exec provisioner to SCP the Kubeconfig file to our Cloud9 instance in order to run commands on our cluster.

Utilizing the remote-exec Provisioner to Run Commands on EC2 Instances Preview 05:35

In this lesson, we're going to use the remote-exec provisioner to check for the existence of the Kubeconfig file on our EC2 instance so we can SCP it over when it is available instead of using an arbitrary wait time.

Terraform Apply Yourself! - Cleanup and Create a Destroy Provisioner Preview 06:40

In this lesson, you're going to Terraform Apply Yourself and create a provisioner to delete the Kubeconfig file when we destroy our infrastructure.

Deploying K8s Resources from our Cloud9 Instance! Preview 03:12

In this lesson, we're going to deploy some resources onto our node directly from our Cloud9 instance instead of remoting into the node!

Kubernetes Section Read Me First! Preview 00:47

Configuring the Kubernetes Provider Preview 04:21

In this lesson, we will configure the Kubernetes provider in order to start deploying Kubernetes resources!

Our First Kubernetes Deployment! Preview 04:08

In this lesson, we're going to deploy our first Kubernetes deployment using Terraform!

Terraform Apply Yourself- Utilizing for_each in our Deployment Preview 06:22

In this lesson, you're going to Terraform Apply Yourself and convert the deployment to utilize for_each to deploy multiple deployments.

The terraform_remote_state datasource and the split Function Preview 08:01

In this lesson, we're going to use the terraform_remote_state datasource and the split function in order to grab our Kubernetes filename and automatically configure our provider.

What We're Going to Build Preview 03:49

In this lesson, we'll cover what we're going to be building over the next several lessons from a high-level view.

Update - New Terraform Cloud UI! Preview 01:02

Hashicorp has made a few updates to the Terraform Cloud interface since I recorded this section. Don't worry! There do not appear to be any breaking changes and they did not hide anything, they just added a few extra features and I wanted to make sure you saw them.

Setting up our Github Preview 05:16

In this lesson, we're going to clone an existing Github repository and push it to our own so we can deploy resources from it.

Configuring Terraform Cloud Preview 04:54

In this lesson, we're going to configure our Terraform Cloud to interact with our Github Repository.

Our First Cloud Deployment! Preview 09:22

In this lesson, we're going to deploy a monolithic AWS deployment using Github and Terraform Cloud VCS connections!

Configuring Repository-Based Modules Preview 06:36

In this lesson, we're going to configure modules from Github Repositories that will allow for a more flexible workflow.

Utilizing the Configuration Designer to Create a Deployment Preview 04:46

In this lesson, we're going to utilize the Configuration Designer in Terraform Cloud to design a new deployment using our modules.

Github Provider version 4.15 currently broken! Preview 00:09

Setting up Providers for our New Deployment Preview 05:41

In this lesson, we're going to start configuring the Terraform deployment that will deploy our new infrastructure we configured using modules.

Configuring our Github Resources in Terraform Preview 05:58

In this lesson, we will add our Github resources to our deployment using the Github Provider.

Configuring our Terraform Cloud Resources in Terraform Preview 08:06

In this lesson, we're going to add the Terraform Cloud resources to our deployment using the tfe provider.

Deploying our Module-Based Infrastructure! Preview 05:47

In this lesson, we're going to deploy our modular infrastructure in a completely automated fashion using only a Terraform script and Terraform Cloud!

Pushing and Pulling Remote State Preview 05:44

In this lesson, we're going to investigate the terraform state push and terraform state pull commands to see how to manage our state from afar.

Updating our Deployment and Destroying it Preview 06:21

In this lesson, we're going to destroy our infrastructure in the proper order and delete our tokens and keys for security.