
Install and use Terraform to provision AWS infrastructure, covering variables, state, modules, VPC, EC2, RDS, Route 53, then Docker with ECR/ECS and Jenkins-driven deployment.
Use discussion groups and the Learn DevOps Facebook community to get feedback and support, with a barcode or link provided after this introduction movie.
Contains useful information for this course
Introduction to what terraform is.
An explanation of how to install terraform on Windows / MacOS / Linux
Install Terraform on Windows, add it to the system path, and verify the version 0.11.7; generate and save SSH keys with PuTTYgen for future SSH access using PuTTY.
An alternative installation procedure using Vagrant. This will allow you to use exactly the same setup I have!
First steps in terraform: learn how to spin up your first instance. First: AWS account setup.
First steps in terraform: learn how to spin up your first instance
First steps in terraform: how can we improve our previous example
Summary of the first steps in terraform
How to use variables in terraform
Using outputs in terraform you can output information on screen
This lecture explains the terraform state file: terraform.tfstate
Our first steps demo, but now with a VPC
Our first steps demo, but now with a VPC, Security Group, and SSH key
Introduction to functions using file("inputfile") and templatefile("inputfile", <map>)
Provisioning an ec2 instance using the user_data approach
If you cannot use the cloud provisioner, have a look at the remote exec and local exec functionality
This lecture shows how to store the terraform.tfstate file remotely. We'll be using S3 (for storage) and DynamoDB (for locking)
An overview of how datasources work
A quick intro to local variables and where they make sense
There's more than just AWS in terraform. An overview of other providers.
A lesson on what commands and arguments are available with the terraform command
intro to the AWS section.
An introduction to AWS VPCs (Virtual Private Cloud) - Part 1
An introduction to AWS VPCs (Virtual Private Cloud) - Part 2
An introduction to AWS VPCs (Virtual Private Cloud) - Part 3
A demo showing you how to launch a VPC with an internet gateway and a NAT gateway
Now that we have created our VPC, we can launch EC2 instances in the VPC
This is a demo showing you how to launch instances within a VPC
This lecture shows you how to use EBS (Elastic Block Storage) with an instance
This demo shows you how to attach EBS volumes to EC2 instances
Userdata can be used to execute commands at launch time
In this demo userdata will be used to format and mount an EBS volume if no filesystem is present. This way EBS volumes can be persisted in an automated way when the instance needs replacement.
This lecture explains the difference between private static IPs, EIPs and DNS (Route53)
This demo shows how to use Route53 to create DNS zones in AWS
This lecture explains how to spin up an RDS (relational database service) instance with terraform on AWS
In this demo I will spin up an RDS instance (using RDS subnets, RDS parameter groups, and security groups) and will connect from an EC2 instance to MariaDB..
IAM stands for Identity & Access Management. In this lecture I explain the different possibilities for access management. I explain users, groups, policies, and roles.
In this demo I create a group with an AWS group policy and attach it to a user.
IAM roles can be used to assume (temporary) access. In this lecture I explain how this works.
IAM roles can be used to assume (temporary) access. In this lecture I show you how to attach a role to an EC2 instance that will give permissions to read/write to an S3 bucket.
A lecture explaining how to setup autoscaling in AWS using terraform
A demo of autoscaling using terraform on AWS
Introduction into Elastic Load Balancers and Application Load Balancers in AWS
This lecture explains how to use ELBs in terraform with a static list of instances and an autoscaling group
A demo showing how to use terraform with an ELB together with autoscaling
An introduction of how the Application Load Balancer (ALB) works in terraform
ElasticBeanstalk (AWS's PaaS solution) setup using Terraform
ElasticBeanstalk (AWS's PaaS solution) setup demo using Terraform
Master Terraform interpolation by using variables, maps, lists, lookups, and data sources; reference resource attributes; and module outputs; apply count, path, and workspace information to create dynamic configurations.
Learn conditionals in Terraform by using interpolations with if-else clauses, applying the count attribute to environments like production and develop to manage redundancy and costs.
Explore how interpolation and conditionals drive Terraform deployments with the AWS VPC module, creating prod and dev VPCs, subnets, security groups, and environment-aware AMIs.
Explore Terraform built-in functions, including file, base name, coalesce, element, format, join, lookup, map, merge, replace, split, substring, timestamp, upper, uuid, and values, with practical syntax examples.
Explore built-in functions in the Terraform console to manipulate strings, lists, and maps with examples like replace, timestamp, split, join, slice, lookup, and substring.
Since terraform 0.12 you can use loops with for and for each. This lecture explains how and when to use for/foreach
For loops demo in terraform
For-each loops demo in terraform
Structure Terraform projects for production isolation by separating development and production environments, using modules for VPC and instances, and storing state in S3 with dev and prod directories.
Explore a Terraform project structure with dev and prod directories, modules for VPC and instances, and outputs that pass data between modules.
The terraform providers lock file was introduced in terraform 0.14 and will from now on keep track of your provider and module dependency versions.
Terraform uses a state file (local / remote) that you can list resources of, read, and manipulate
Demo showing how to manipulate the state file in terraform
With packer AMIs can be created that can be used to launch an EC2 instance.
Where does Terraform fit in the DevOps organization? In this lecture I show you an example workflow with terraform, packer and jenkins
Packer can be integrated with terraform. This workflow shows how to create a workflow where packer creates the AMI and terraform launches the EC2 instance with the correct AMI ID
This demo shows a full cycle of an app in github, the building of a custom AMI with packer in Jenkins and the provisioning and deployment with Terraform
This demo shows a full cycle of an app in github, the building of a custom AMI with packer in Jenkins and the provisioning and deployment with Terraform
This lectures gives an introduction of Docker
This lecture explains how to use Docker on AWS using terraform
This lecture shows how to build docker images that can be pushed on ECR
In this demo I show how to push a docker built image to ECR
This lecture explains part I of the setup of ECS using terraform, with autoscaling and IAM roles
This lecture explains part II of the setup of ECS using terraform, with autoscaling, IAM roles, ECS task definitions and ECS Service definitions
This demo shows you how to run the pushed NodeJS app on ECS
In this demo I show you how to run a Jenkins workflow to build docker images, push the image to ECR, and use terraform to update ECS with the latest docker image
Explore how terraform modules enable reuse via external community modules and self-written options, including aws vpc, alb, and eks modules; see a demo building an ecs module with an alb.
Explore how the ECS cluster, IAM roles, security groups, and auto scaling feed an ALB with a target group and ACM SSL, using four modules.
Explore how the ECS and ALB Terraform modules deploy an ECS cluster behind an application load balancer, wiring VPC, IAM roles, CloudWatch logs, and a docker service.
Explore the ALB module for ECS deployments, configuring a secure HTTPS listener with ACM certificate, default and optional rules, and dynamic ECS port mappings behind a load balancer.
Request and verify a domain certificate in aws certificate manager to enable https, then deploy ecs behind an alb with nginx image pushed to ecr via the terraform module.
What features were released in terraform 0.12 and 0.13 to allow us to do more advanced module development?
This lectures explains what the difference between count and for_each is in terraform
Demonstrates using for_each with a module to create multiple AWS SSM parameters from a map, and outputting their ARNs for reuse.
This demo explains how to use the flatten() function with complex data types.
Refactoring modules with the "moved" block in terraform
Terraform has gained a lot in popularity lately and is the tool you need to master if you are or about to get into an Ops / DevOps role. You typically use a technology like Ansible, Chef, or Puppet to automate software provisioning. Terraform starts from the same principle, infrastructure as code, but focuses on the automation of the infrastructure itself. Your Cloud infrastructure (instances, volumes, networking, IPs) can be described in terraform.
In this course, you'll learn how to use Terraform to automate your infrastructure. I will first show you the basics of Terraform and then explain how to automate infrastructure on AWS using Terraform. You can open an AWS account for free to do the labs. I also provide many code examples that you can immediately use to automate your own infrastructure.
Last Updates, November 2024:
Complete revision of Section 3: terraform basics
Updated lessons where terraform, or the AWS provider has made changes
The course gets regular updates when the AWS provider or terraform makes changes. Some lessons and demos are very old, but if there's no changes to be made, I keep the old recording. Reach out to me if there is a demo that doesn't work: every demo should be working using the demo code on my GitHub repository.
This course includes english captions.