Terraform & Devops
  • Home
  • TERRAFORM CERTIFCATION
  • AWS-CLOUD
  • GCP-CLOUD
  • ANSIBLE
  • KUBERNETES
  • Aboutus
  • Contact Us
No Result
View All Result
  • Home
  • TERRAFORM CERTIFCATION
  • AWS-CLOUD
  • GCP-CLOUD
  • ANSIBLE
  • KUBERNETES
  • Aboutus
  • Contact Us
No Result
View All Result
Terraform & Devops
No Result
View All Result
Home TERRAFORM CERTIFCATION

Terraform – Modules

All About Terraform Modules

by abubakarsiddiq858
January 4, 2021
in TERRAFORM CERTIFCATION
192 4
0
Terraform – Modules
224
SHARES
2.8k
VIEWS
Share on FacebookShare on Twitter

Terraform Modules

In this article we will Teach you what is a module how to write a module , how to call a module what is root module, child module.

  • A module is a collection of .tf files

  • the main use of mosules is reusability

The structure of module:

In the above diagram we can see

  • tf means it consists of providers information.

  • tf means it consists of resources information

  • tf consists of attributes information of a resource

  • tf consists of variables information of the resources

Definition of Module:

A module is a container for multiple resources that are used together. Modules can be used to create lightweight abstractions, so that you can describe your infrastructure in terms of its architecture, rather than directly in terms of physical objects

Procedure for using Modules:

  1. Create a Folder and put it in .Tf file that defines the resource creation.this file is treated as parent Module.

Example:

resource "aws_instance" "myec23" {
ami = "ami-08f63db601b82ff5f"
instance_type = "t2.large"
tags = {
name = "myec3"
}
}
output "hello" {
value = aws_instance.myec23.id
}

In the above example we referred code to create a server and in order to view the id of the server on the console  we used ID attribute.

Calling the module:

To call a module we need to specify the code of parent module in source block .

The syntax is as follows:

module "helloworld"
{
source = "./parentmoduleloaction”
}
To acess the ouput values in modules we need to fallow the syntax
output "vn"{
value=module.mn.routputvariablename.atrn
}

Here in this example “helloworld is module name and Hello is the output variable name of the parent module.

 

Publishing Modules to Terraform Registry:

Once the module is created we can publish it to terraform registry.

The steps are as follows:

Step1:we need to push the code to  GITHub

Procedure for pulling Code to Github.

Execute the following list of commands

Ø  create a repository that is a Folder

Ø  Intitize the Repositoty

Ø  Execute the command git init

Ø  Add the files using command git add .

Ø  git commit -m “myfirstcommitec2”

Ø  git tag -a “v1.o” -m “version1 code”

Ø  git push

Ø  git push -uf origin master –fallow-tags

step2:

Step2:we need to login to https://registry.terraform.io/ and click on publish module.

Wow that’s cool you created and published module successfully.hope this artcle helpful for you in creating and publishing modules.

  • Trending
  • Comments
  • Latest
Terraform – Modules

Terraform – Modules

January 4, 2021
Terraform Life cycle

Terraform Life cycle

January 4, 2021
Terraform – Functions

Terraform – Functions

January 4, 2021
Terraform installation

Terraform installation

January 4, 2021
Implementing VPC Architecture using Terraform

Implementing VPC Architecture using Terraform

0
Local and dynamic blocks:

Local and dynamic blocks:

0
Terraform  Provisioners

Terraform Provisioners

0
Managing Terraform States in Remote Locations:

Managing Terraform States in Remote Locations:

0
Implementing VPC Architecture using Terraform

Implementing VPC Architecture using Terraform

August 28, 2021
Build a CICD Pipeline with Git Jenkins Terraform

Build a CICD Pipeline with Git Jenkins Terraform

May 24, 2021

Configuring VPC Components in AWS

February 8, 2021

Introduction to AWS

February 7, 2021

Recent News

Implementing VPC Architecture using Terraform

Implementing VPC Architecture using Terraform

August 28, 2021
Build a CICD Pipeline with Git Jenkins Terraform

Build a CICD Pipeline with Git Jenkins Terraform

May 24, 2021

Categories

  • Uncategorized
  • AWS-CLOUD
  • TERRAFORM CERTIFCATION

Site Navigation

  • Home
  • Advertisement
  • Contact Us
  • Privacy & Policy
  • Other Links
Terraform & Devops

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Check our landing page for details.

No Result
View All Result
  • Home
  • TERRAFORM CERTIFCATION
  • AWS-CLOUD
  • GCP-CLOUD
  • ANSIBLE
  • KUBERNETES
  • Aboutus
  • Contact Us

© 2021 TheTerraform.in - All Rights Reserved.
Designed By TenXinfotech.

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms below to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In

Add New Playlist