Terraform: Step-by-Step Activity Guide (Hands-on Lab) & Project Work for getting a Job

Terraform Activity Guides
Terraform

Share Post Now :

HOW TO GET HIGH PAYING JOBS IN AWS CLOUD

Even as a beginner with NO Experience Coding Language

Explore Free course Now

Table of Contents

Loading

This blog post acts as your gateway to unlocking a rewarding career in Terraform, empowering you to become an expert in infrastructure as code. Immerse yourself in our engaging Step-By-Step Activity Guides and Real-time Projects, meticulously designed not only to enhance your CV but to pave the way for your dream job. Acquire the skills sought after by employers, build an impressive CV, and position yourself for success in job interviews.

Additionally, these resources are tailored to help you confidently tackle certification exams such as HashiCorp Certified: Terraform Associate (TCA). Your journey to a fulfilling job in the dynamic world of infrastructure automation with Terraform starts here!

HashiCorp Certified Terraform Associate

The Activity Guides are divided on the basis of different Cloud Providers, Customer Case Study and Projects:

1)  Terraform on Azure

  1. Register For a Free Azure Cloud Account
  2. Installing Terraform with Azure
  3. Create A Resource Group
  4. Define Input & Output Variables
  5. DataSources
  6. Dynamic Blocks
  7. Provisioners – local-exec, remote-exec, file
  8. Remote State with Azure Storage Account
  9. Terraform Modules
  10. Create & Manage Workspaces
  11. Terraform CLI Commands
  12. Create Virtual Network & Virtual Machine

2) Terraform on AWS

  1. Register for AWS Free Tier Account Amazon Web Services
  2. Installing Terraform with AWS
  3. Create VMs (EC2) on AWS Cloud Shell Using Terraform: Quick Start
  4. Creating An EC2 Instance
  5. Modifying and Deleting Resources
  6. Creating VPC and Subnet
  7. Building a small Infrastructure
  8. Input & Output Variables
  9. Functions, DataSource & Dynamic Block
  10. Terraform Provisioners
  11. Modules & Workspaces
  12. Terraform Remote State With AWS
  13. Security Primer

3) Terraform on OCI

  1. Register For Oracle Cloud Trial Account
  2. Installing Terraform on a Linux Instance on OCI
  3. Adding API Keys and creating a VCN
  4. Installing OCI CLI
  5. How to Define Input & Output Variables
  6. Fetch Data Using Datasource
  7. Creating a WebServer using Provisioner

4) Customer Case Study

5) Projects

  • AWS Projects
  • Azure Projects

Read about types of input Terraform variables, output variables, and how to define them in terraform configuration.

Terraform on Azure

Activity Guide I: Register For a Free Azure Cloud Account

The first thing you must do is to get a Trial Account for Microsoft Azure. (You get 200 USD FREE Credit from Microsoft to practice)

Microsoft Azure is one of the top choices for any organization due to its freedom to build, manage, and deploy applications. Here, we will look at how to register for the Microsoft Azure FREE Trial Account, click here.

Check out our blog to learn how to create a Free Azure account.

Azure Email Confirmation

 

Activity Guide II: Installing Terraform with Azure

This guide walks you through installing the Azure CLI, Microsoft Azure’s command-line interface, and adding the Azure provider to Terraform while initiating it with the Terraform init command. These steps are essential for preparing your environment to manage Azure resources using Terraform.

Azure CLI

Also see A basic introduction of Terraform providers and some major Terraform cloud providers such as AWS, Azure, and OCI.

Activity Guide III: Create A Resource Group

This activity guide explains the process of creating a Resource Group in Azure using a Terraform Configuration File. It provides instructions for running essential Terraform commands, including terraform init, terraform plan, and terraform apply, to facilitate the creation and management of the Resource Group efficiently.

Azure RG

Activity Guide IV: Define Input & Output Variables

This guide teaches how to define and use different types of input variables (lists, tuples, maps, objects) in Terraform configurations. It demonstrates how to reference these variables in your code and execute it, enabling flexible infrastructure management.

Input-Output Variables

Check Out: What is Terraform? Click here

Activity Guide V: DataSources

Data sources allow a Terraform configuration to make use of information defined outside of Terraform or defined by another separate Terraform configuration. In this section, you will Create a VNet by fetching the information of an existing resource group using Terraform Data Source.

This guide focuses on utilizing Terraform DataSources to fetch resource group data from an Azure environment. It demonstrates how to create Terraform configurations that extract valuable information about Azure resource groups, such as their names, locations, and associated tags.

Azure Data Source

Activity Guide VI: Dynamic Blocks

This activity guide focuses on the creation of a Virtual Network (VNet) within the context of infrastructure provisioning using Terraform. Specifically, it illustrates the process of creating a VNet with three dynamically generated subnets, employing dynamic blocks in Terraform configurations.

Azure Dynamic Block

Check Out: Our blog post on Terraform Workflow. Click here

Activity Guide VII: Provisioners – local-exec, remote-exec, file

This activity guide demonstrates the creation of a Virtual Network (VNet) and a Virtual Machine (VM) using Terraform. It also showcases the utilization of Terraform’s provisioners for enhanced VM configuration. Specifically, it covers the addition of a local-exec provisioner to record the VM’s public IP address in a local file, a remote-exec provisioner for installing Git on the VM, and a file provisioner for copying a local file to the VM’s directory in Azure.

Azure Provisioners

Activity Guide VIII: Remote State with Azure Storage Account

This guide covers three key tasks: creating an Azure Storage Account using the Azure Command-Line Interface (az cli), setting up remote Terraform state storage in the Azure Storage Account, and understanding the functionality of Terraform’s ‘terraform refresh’ command. It equips users to manage infrastructure efficiently while securely storing Terraform state in Azure Storage.

Azure Remote State

Check Out: Terraform Commands Cheat Sheet. Click here

Activity Guide IX: Terraform Modules

This activity guide provides instructions for creating and using Terraform modules to streamline infrastructure management in Azure. It demonstrates how to create modules for Azure Storage Accounts and Virtual Networks, then integrate these modules into a root module. The guide follows a directory structure, with ‘Modules_Demo’ serving as the root directory.

TF Azure Modules

Activity Guide X: Create & Manage Workspaces

This activity guide provides instructions for working with Terraform workspaces, focusing on key actions such as creating multiple workspaces, managing them using Terraform workspace commands (show, new, list, select, delete), and implementing workspaces through a straightforward configuration file.

Azure Workspaces

Activity Guide XI: Terraform CLI Commands

This guide focuses on three critical Terraform CLI commands. Firstly, ‘terraform import’ enables the incorporation of existing resources into Terraform’s management. Secondly, ‘terraform fmt’ automates the formatting of Terraform configuration files, ensuring consistent and readable code.

The Terraform import command is used to import existing resources into Terraform. Using terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style. Using Terraform taint command to manually mark a Terraform-managed resource as tainted, forcing it to be destroyed and recreated on the next apply.

Activity Guide XII: Create a Virtual Network & Virtual Machine

In this guide, we demonstrate how to build a small Azure infrastructure using Terraform. This includes creating a Virtual Network (VNet) with subnets, public IP, network security, and a network interface. Afterward, we set up a virtual machine within this configured environment.

Azure VM

Terraform on AWS

Activity Guide I: Register for AWS Free Tier Account Amazon Web Services

This activity guide cover steps to how to create a new AWS Free Tier Account | Amazon Web Services and Login To AWS Console

AWS Cloud

Activity Guide II: AWS Installing Terraform

This activity guide provides a concise overview of three key aspects when using Terraform to manage AWS resources. It outlines the process of adding an AWS provider to establish a connection with your AWS account. It also highlights the importance of securing your AWS credentials to validate Terraform operations, and lastly, it explains how to generate and manage AWS secret credentials, an essential step in ensuring the security of your infrastructure provisioning and management with Terraform.

AWS Terraform

Activity Guide III: Create VMs (EC2) on AWS Cloud Shell Using Terraform: Quick Start

In this activity guide, we will provide a concise walkthrough of a specific task: setting up two virtual machines (VMs) within the AWS Cloud Shell environment using Terraform. This guide will focus on the essential steps to create and manage these VM instances, offering a practical solution for provisioning resources in an AWS cloud environment.

AWS Cloud shell

Activity Guide IV: AWS Creating an EC2 instance

This activity guide provides a concise overview of essential aspects when using Terraform to create an EC2 instance on AWS. It introduces the syntax involved in defining an EC2 instance within a Terraform configuration. It also guides you through fundamental Terraform commands, including terraform init for initialization, terraform plan for infrastructure preview, and terraform apply for actual resource provisioning.

AWS Ec2

Check out: How to Install Terraform in Linux, Mac, Windows

Activity Guide V: AWS Modifying and Deleting Resources

This activity guide provides a concise overview of essential tasks when using Terraform to manage AWS EC2 instances. It encompasses the process of modifying a resource, which allows you to adapt to changing infrastructure needs, and the removal of specific resources to streamline your environment. Additionally, it explains the procedure for destroying all resources, a vital step when resources are no longer required, enabling you to efficiently manage your AWS infrastructure with Terraform.

Ec2 Deletion

Activity Guide VI: AWS Creating VPC And Subnet

This activity guide provides a concise overview of fundamental tasks when utilizing Terraform to establish an AWS Virtual Private Cloud (VPC) and its associated subnets. It outlines the process of creating the VPC, which serves as a secure network environment, and creating subnets within it. These subnets are essential for segmenting your network resources, achieving isolation, and aligning with specific architectural requirements, making it a crucial starting point for building robust cloud infrastructure using Terraform.

AWS VPC

Activity Guide VII: Building a Small Infrastructure

This activity guide provides a concise overview of essential tasks for building a comprehensive AWS infrastructure using Terraform. It covers the creation of a Virtual Private Cloud (VPC), Internet Gateway, custom route table, subnets, and the association of subnets with route tables. Additionally, it outlines the configuration of security groups, network interfaces, and Elastic IP addresses, all culminating in the launch of an Ubuntu instance. These tasks collectively form the foundation for establishing a versatile and secure cloud environment using Terraform.

AWS Infra

Activity Guide VIII: Input & Output Variables

This activity guide offers a concise overview of key tasks when working with Terraform variables. It covers the creation of input and output variables, providing insights into various approaches to assign values to variables. It also explains different variable types and the implementation of validation rules for ensuring data integrity in your infrastructure configurations. This guide equips you with fundamental knowledge to effectively utilize Terraform’s variable capabilities in managing cloud infrastructure.

AWS Variable

Activity Guide IX: Functions, DataSource & Dynamic Block

This activity guide offers a concise overview of fundamental aspects when working with Terraform variables. It includes creating input and output variables, providing insights into different methods for assigning values to these variables, and an explanation of various variable types. Understanding these core concepts will enable you to effectively harness Terraform’s variable capabilities when managing and provisioning resources in your infrastructure configurations.

AWS Datasource

Activity Guide X: Terraform Provisioners

The guide explores the Terraform provisioning process, emphasizing the use of these provisioners to execute commands, scripts, and files during infrastructure deployment. It delves into the intricacies of each provisioner type, highlighting their unique features, benefits, and best practices.

AWS Provisioners

Activity Guide XI: Modules & Workspaces

This guide aims to provide a comprehensive understanding of Terraform modules and workspaces. It covers essential topics such as the fundamental concepts of Terraform modules and best practices for structuring and utilizing them within your configurations. Additionally, it delves into the usage of Terraform workspaces, offering insights into creating and managing multiple workspaces. You will also learn how to implement workspace-specific configurations for virtual machines, allowing for customization of virtual machine sizes to cater to the unique requirements of each workspace.

AWS Modules

Activity Guide XII: Terraform Remote State With AWS

This guide is designed to help you achieve a comprehensive understanding of critical Terraform practices in AWS. Firstly, you will explore Terraform Remote State, its significance in maintaining infrastructure state, and the practical steps to configure and leverage this feature within an AWS environment. Next, you’ll delve into Terraform State Locking using DynamoDB, gaining insight into its role in conflict prevention when multiple users or processes collaborate on the same infrastructure.

AWS remote state

Activity Guide XIII: Security Primer

In this activity guide, you’ll find a concise overview of essential security practices for Terraform in an AWS environment. It covers the steps for setting up the AWS Command Line Interface (CLI) and demonstrates how to manage authentication securely using environment variables. These practices are crucial for enforcing robust security measures and access control when working with Terraform in an AWS infrastructure.

AWS Security

Also read: Step-by-step guide on Terraform Certification

Terraform on OCI

Activity Guide I: Register For Oracle Cloud Trial Account

This activity guide cover steps to

  •  Create a FREE Trial account on Oracle Cloud
  • Access other cloud services
  • OCI Console Walkthrough
  • OCI Direct Login Process
  • Raise SR for Oracle Support
  • Requesting a Service Limit Increase in OCI

Activity Guide II: Installing Terraform on a Linux Instance on OCI

Oracle Cloud Infrastructure Compute lets you provision and manages to compute hosts, known as instances. You can launch instances as needed to meet your compute and application requirements.

In this activity guide, you will learn how to Create a Linux Compute and Install Terraform on the compute on Oracle cloud

Terraform: Activity Guide

Activity Guide III: Adding API Keys and creating a VCN

Once you created an instance, you need to set up a Terraform Environment on the local computer as well as on Linux.

After that:

  • Run a basic terraform apply to create a VCN.
  • Destroy the created VCN

Terraform: Activity Guide

Activity Guide IV: Installing OCI CLI

This activity guide you will learn about  Installing OCI CLI on your local machine. and Configuring the installed CLI.

Activity Guide V: How to Define Input & Output Variables

Defining different types of input variables such as lists, strings, and output variables in Terraform configuration.

Initializing these Variables and providing value to the variables.

Activity Guide VI: Fetch Data Using Datasource

Fetching data to get a list of Availability Domains, get the ID of OS Image, VNIC Attachments and VNIC.

Activity Guide VII: Creating a WebServer using Provisioner

In this activity guide we will look at

  • Using Resource blocks
  • Creating a Webserver.
  • Using provisioner.

Customer Case Study

In this guide, we have covered the actual Architectural setup on how to build the infrastructure on OCI by using terraform that we did for one of our Clients.

Terraform on OCI

Projects

AWS Projects

Building a Flexible and Scalable Load Balancer in AWS with Terraform

In this guide, we will be using Terraform to build a Virtual Private Cloud (VPC) in AWS. The VPC will include 2 subnets, route tables, internet gateways, and security groups. The code will be flexible enough to accommodate opening ports in an easy way.

AWS LB

Deploy Elastic Kubernetes Service (EKS) With Terraform (Bonus)

In this guide we covered:
Setting up AWS Kubernetes Cluster (EKS)
– Setup EKS Cluster using Terraform
–  Install kubectl
– Setup kubectl configuration
– Check worker node status
– Delete the EKS cluster using terraform

AWS EKS

Building an Automated CI/CD Pipeline for Terraform with GitHub Actions and S3

In this comprehensive guide, you will learn how to set up an automated CI/CD pipeline for your Terraform infrastructure using GitHub Actions and AWS S3. This includes creating a GitHub repository, managing AWS credentials securely, configuring secrets, and developing Terraform scripts to provision resources. By following these steps, you will achieve one-touch infrastructure automation, ensuring efficient and reliable deployment of your infrastructure-as-code projects.

AWS CICD

 

Create & Deploying a 3-Tier AWS VPC Architecture Using Terraform

In this Guide, we have created

  1. A Virtual Private Cloud (VPC) with the IP address range 10.0.0.0/16, consisting of:
  2. Two public subnets with IP address ranges 10.0.1.0/24 and 10.0.2.0/24.
  • One private subnet with the IP address range 10.0.3.0/24.
  • An Amazon RDS (Relational Database Service) MySQL instance, utilizing the t3.micro instance type.
  1. An Elastic Load Balancer (ELB) is configured to route and distribute incoming network traffic to the public subnets within your VPC.

AWS 3tier

 

Azure Projects

Automating Azure Infrastructure(Virtual Network, Subnet, and Load Balancer) Setup with Terraform

In this use case, we will be utilizing Terraform, an infrastructure-as-code tool, to create an Application Load Balancer (ALB) in Azure. The ALB plays a crucial role in distributing incoming network traffic across multiple backend resources to enhance availability and scalability of applications. By automating the ALB deployment process with Terraform, we can ensure consistent infrastructure provisioning and simplify the management of our Azure resources.

Azure LB

Deploy Azure Kubernetes Service (AKS) With Terraform

This guide covers essential steps for setting up and managing an Azure Kubernetes Service (AKS) cluster using Terraform. It includes instructions on installing Terraform, configuring Azure CLI, creating Terraform code for AKS cluster deployment, executing the Terraform code, installing kubectl for cluster access, and finally, how to safely destroy the Kubernetes cluster when it’s no longer needed. These steps provide a comprehensive overview of the AKS provisioning and management process with Terraform.

Azure AKS

Certification

HashiCorp Terraform Associate Certification (003)

The HashiCorp Terraform Associate Certification (003) signifies expertise in infrastructure as code using Terraform. Developed by HashiCorp, this certification validates skills in Terraform syntax, configuration, and resource management. It serves as a valuable credential, demonstrating a professional’s proficiency in automating infrastructure deployment. Employers recognize and trust this certification as a standard for assessing a candidate’s ability to contribute effectively to Terraform projects, making it a key asset for those navigating the evolving landscape of cloud computing and DevOps practices.

Terraform 003 badge

Related/References

Join FREE Class

🚀 Master Terraform & DevOps to get High-Paying Jobs! 🔥 Join our EXCLUSIVE Free class! 🚀

Get your hands dirty with lots of projects and labs based on Terraform and DevOps in our Program.Click on the below image to Register for Our FREE Class Now!

MAstering terraform and Devops freeclass

Picture of mike

mike

I started my IT career in 2000 as an Oracle DBA/Apps DBA. The first few years were tough (<$100/month), with very little growth. In 2004, I moved to the UK. After working really hard, I landed a job that paid me £2700 per month. In February 2005, I saw a job that was £450 per day, which was nearly 4 times of my then salary.