Skip to main content

Command Palette

Search for a command to run...

TerraWeek Day 2

Day -2 #Terraweekchallenge

Published
β€’2 min readβ€’View as Markdown
TerraWeek Day 2
N

Nikhil Patil

πŸ‘¨β€πŸ’» I love Linux & DevOps! πŸ’»

🐧 LinuxπŸ‘¨β€πŸ’» | DevOps & Cloud Enthusiast | 🌍 Azure Admin | πŸ› οΈ Ansible | πŸ“‚ Git | 🐳 Docker | πŸ”‘ OpenLDAP | πŸ–₯️ System Admin | | πŸš€ Jenkins πŸ› οΈ

🏠 Pune

🌟 I'm really into using and managing computers with Linux. I also like making things work smoothly and quickly.

πŸ“– I work with Microsoft Azure, use tools like Ansible and Git to automate tasks, and make software run in containers with Docker.

πŸ”’ I handle access and security using OpenLDAP, and I'm all about keeping systems running smoothly.

🌐 Exploring opportunities in cloud and DevOps.

πŸ“§ Get in touch: nikrpatil1997@gmail.com

πŸ“Œ Task 1: Familiarize yourself with HCL syntax used in Terraform

Learn about HCL blocks, parameters, and arguments

Blocks -

HCL uses blocks for different sections and resources in a configuration. HCL files are typically .tf extension and it contains configuration for infrastructure creation.

Parameters -

Parameters are the key-value pair inside the block that define the attributes of the resource

Argument -

Arguments are the values that are assigned to parameters.

resource "resource_name" "resource_lable" {
parameter1 = value
parameter2 = value
}

In the above block resource_name is a resource that we want to create and the resource_label is the name of the resource and the parameters and their value required for configuration

Explore the different types of resources and data sources available in Terraform

We will see some resources for Azure

resource "azurerm_resource_group" "testrg" {
name = Nikhil-RG
location = "eastus"
}

So the above block we defined a block for the creation of an Azure resource group The resource is azurerm_resource_group and label is testrg and the name, and location are the parameters.

πŸ“Œ Task 2: Understand variables, data types, and expressions in HCL

Create a variable.tf file and define a variable.

Create the file variable.tf

Use the variable in a main.tf file to create a "local_file" resource

Create the main.tf

Apply the file

πŸ“Œ Task 3: Practice writing Terraform configurations using HCL syntax

Add required_providers to your configuration, such as Docker, AWS, or Azure

In the below block, we added the provider for Azure

Test your configuration using the Terraform CLI and make any necessary adjustments

Now we will create one resource group in Azure to test the configurations.

Apply the file to create resources

successfully created a resource group using the terraform apply command

Thank You