Terraform

How to destroy resources through Terraform?

In 3 ways we can destroy the resources through Terrafrom. 1.From the terrafrom init directroy – Where you keep the actual config files,2.Specifying the target with provider,3.Remove the resource code from your tf file. Option1: – From the terraform init directory #terraform destroy Here it will show clearly what are the resources can be deleted . In this example “yourec2”…

Continue Reading

Terraform

How to create repository in GitHub through Terraform?

Before Terraform steps first we have to create access in GitHub . Access in github can be granted through Personal Access Token. How to create Personal Access Token in GitHub? Login into Your github account. Click settings Click Developer Settings Click Personal Access token – Click Generate new Token if already not created . Enable repo in the scopes Now…

Continue Reading

Terraform

Understanding the variables in Terraform – Test

For this testing created “ter-demo” dir and created files under this directory. 1.vars.tf In this file we defined what are actual variables (like syntax) going to use and equivalent values options. For AWS_REGION and AMIS defined default options.For AWS_ACCEES_KEY and AWS_SECRET_KEY it can get input from other file or from user . 2.instance.tf This file has actual contents to create…

Continue Reading

Terraform

Terraform variable types and values

Types 1.String A sequence of Unicode characters representing some text Example : “hello” Strings are usually represented by a double-quoted sequence of Unicode characters, “like this”. 2.Number A numeric value . Numbers are represented by unquoted sequences of digits with or without a decimal point, like 15 or 6.283185 3.Bools Bools are represented by the unquoted symbols true and false. Bool values can be used in conditional logic.…

Continue Reading

Terraform

Launching your first aws ec2 instance through Terraform

Before launching aws ec2 instance need to setup aws iam user account . You can refer this article how to setup aws iam user account. 1.You can create “launch” directory (any name you can select) 2.Create instance.tf (any name.tf) file and update aws instance related information instance.tf provider “aws” { region = “us-west-2” access_key = “REPLACE-YOUR-ACCESS-KEY-HERE” secret_key = “REPLACE-YOUR-SECRET-KEY-HERE” }…

Continue Reading

Terraform

First Time Terraform Environment Setup in AWS

1.Create AWS Free tier account or use your existing account.https://signin.aws.amazon.com/ 2. To use Terraform in AWS environment first needs to be setup in user account . We have to generate accesskey and secretkey in IAM AWS. 3.Open IAM service and select user 4.Creating console access is optional , but programmatic access is mandatory 5.Create group and provide administrator access .…

Continue Reading

Terraform

Testing with variables in Terraform

After installation of Terraform you can practice with simple variable test. 1.As a first step you have to create main.tf file #vi main.tf variable “myvar” { type = string default = “hello terraform” } variable “mymap” { type = map(string) default = { mykey = “myvalue” } } variable “mylist” { type = list default = [1,2,3] } 2.Testing variables…

Continue Reading

Terraform

How to install Terraform on Linux

Installing Terraform on Linux is so simple , you no need to actually install like ohter software, you can just download the zip package , extract and update the path. 1.Install unzip package sudo yum install unzip sudo apt-get install unzip (ubuntu) 2. Confirm the latest version number on the terraform website: https://www.terraform.io/downloads.html 3. Download latest version of the terraform…

Continue Reading