
Download the PDF
Learn how infrastructure as code enables provisioning, configuring, updating, and destroying resources with tools like Terraform and Ansible, while comparing configuration management, server templating, provisioning, and immutable infrastructure.
Discover how Terraform, an open source IaC tool by HashiCorp, provisions infrastructure across cloud and on-prem platforms via providers, using HCL declarative syntax and the init plan apply workflow.
Install Terraform by downloading the binary from terraform.io, add it to your path, and verify version 0.13 on Linux; learn hcl .tf basics with local file and random pit resources.
Explore the Terraform variable block, including default, type, and description, and learn to use string, number, boolean, list, map, set, object, and tuple types with type constraints.
Link resources by using resource attributes and attribute reference with interpolation to use the random_pet ID as the content of a file resource, creating dependent resources after Terraform apply.
Understand how Terraform state tracks infrastructure by refreshing in-memory state during plan and apply, creating the terraform.tfstate as the single source of truth for resource updates and plan accuracy.
Learn the purpose of state in Terraform, where the state file maps configurations to real infrastructure, enables plans and drift detection, tracks dependencies, and supports remote state for team collaboration.
Discover how Terraform state acts as the single source of truth and stores sensitive details. Learn why to prefer remote backends over Git and avoid manual edits.
Explore the difference between mutable and immutable infrastructure, showing how Terraform creates or destroys resources during updates, explains configuration drift, and introduces lifecycle rules to control order of changes.
Explore meta arguments in Terraform that enable looping to create multiple resource instances, such as loop-related meta arguments beyond depends_on and lifecycle, to automate multiple file resources.
Utilize the count meta-argument to create multiple resources from a filename list using count.index and length to size dynamically, while noting potential replacement risks.
Learn how to start with AWS, explore its core services—IAM, S3, and DynamoDB—and provision them with Terraform using the AWS provider and HCL in hands-on labs.
Guide learners through creating an AWS account, signing in as the root user, and navigating the AWS Management Console to explore services such as EC2, S3, RDS, DynamoDB, and IAM.
Explore identity and access management in AWS, create users and groups with least-privilege policies, attach administrator or custom policies, and use roles to grant EC2 and S3 access.
Discover AWS IAM essentials: create users and groups, attach policies (administrator, EC2 full, S3 full, read-only), and define a read-only EC2 role, with Terraform in the next lecture.
Learn to create IAM policies with Terraform, attach them to a user with aws_iam_policy and aws_iam_user_policy_attachment, following least privilege principle, and work with JSON policy documents via heredoc or admin-policy.json.
Create and manage AWS DynamoDB tables with Terraform using the DynamoDB table resource, define a cars table with a VIN hash key and on-demand billing, then add items.
Manage terraform state with commands like list, show, move, pull, and remove to query resource addresses and attributes, including remote state access, the JSON state format, and safe, nonmanual updates.
Explore AWS EC2 instances, the elastic compute cloud, virtual machines for scalable on-demand deployment of operating systems and software, with AMIs, instance types, EBS storage, and user data scripts.
Explore Terraform provisioners, including remote exec and local exec, to run scripts after resource creation, configure connections (SSH or WinRM), handle failures, and follow best practices over native options.
Learn how to use provisioners in Terraform wisely, balancing remote-exec with native resource options like AWS user data, and build reusable custom AMIs via Packer to minimize post-provisioning tasks.
learn how to import existing infrastructure into Terraform using the terraform import command, updating the state while manually defining the resource block and then managing it with plan and apply.
Where To Start With Terraform Basics
In this course, we will get started with the Terraform basics, but first, we will take a look at infrastructure as a code or IaC, the different types of tools available in IaC, and their purpose in managing modern IT infrastructure. We’ll then see the role of Terraform in today’s IT Infrastructure. We’ll then learn how to install Terraform. This is followed by the basics of Hashicorp Configuration Language (HCL). Next, we have our first lab, where you’ll get your hands dirty with HCL syntax. We will then learn the basics of Terraform, such as Providers, Input and Output variables, Resource Attributes, and Dependencies.
What Is Terraform?
After this, we take a look at the state in Terraform – what it is, why it is used, and considerations to follow when working with the state. We then dig deeper into the fundamentals– starting with the different commands provided by Terraform. This is followed by a lecture where we understand the difference between Mutable and Immutable infrastructure. This is followed by lifecycle rules in Terraform where we will learn how to manage the ways in which resources are created. This is followed by other basic topics such as data sources, meta arguments such as count and for each, and finally understanding of the version constraints in Terraform.
Terraform and AWS
After this, we have a dedicated section on AWS. This section begins with optional lectures and demos where we learn the basics of AWS. – such as setting up an AWS Account and learning about some of the basic AWS services such as IAM, S3, and DynamoDB. We will then see how to provision and manage these services using Terraform. Each of these topics, including the ones for AWS, is followed by hands-on labs where we get to practice the concepts on real infrastructure.
Steps In Learning Terraform
We will then learn Terraform concepts such as remote state and state locking with Terraform and then see how to store state in a remote s3 backend.
Next, we will see how to use terraform state commands to manipulate the state file. We then have a few lectures and demos where we get introduced to EC2 service and learn how to provision it using terraform.
Finally, we will learn about provisioners in terraform – what they are, the different types, behaviors, and considerations to follow when working with provisioners.
We then look at resource taints, learn how to enable debugging, and then import other resources in the management of Terraform, Terraform modules – what they are, how to create them, and also how to make use of modules available in the public Terraform registry.
We will then learn about functions and continual expressions in Terraform and how to test them using the Terraform console.
Next, we will then learn about workspaces in terraform – what they are, how to create them and when to use them.
We will wrap up the course with an introduction and high-level overview of the features offered by Terraform Cloud.