We can give all the variables and equal values in the source code tf files , but problem with that if you like to change the values , you have to modify everywhere in the main source code . It could be complex to implement in production env and it’s not easy to use. So we can use variables in…
How to add rules in aws security group thorugh Terraform?
Creating AWS VPC security group very simple by Terraform. Note: Provider section is mentioned in separate tf file. ingress –> Inbound egress—>Outbound
How to create new AWS EC2 instance and assign EIP using Terraform?
In the other article we have seen how to create aws ec2 instance using Terraform. Now lets see how to create EIP and assign to the EC2 instance automatically using Terraform. In the below example you can insert your provider access key and secret key information’s. Here “aws_eip_association” will do the mapping function for EC2 id and EIP id .…
Displaying output in Terraform
After executing “terraform apply” normally it will show “the resource has been created” with some little information’s. If you like to see more attributes about resources or some specific values after resource creation you have to include output section in your tf source code file. For this example we will consider the scenario for creating EIP and S3 bucket in…
Know about Terraform State Files , Current State and Desired State
Terrafrom stores the state about your managed infrastructure and configuration . State/state files created from the TF files. This state is used by Terraform to map real world resources to your configuration, keep track of metadata. This state is stored by default in a local file named “terraform.tfstate”, but it can also be stored remotely, which works better in a…
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”…
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…
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…
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.…
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” }…
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 .…
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…
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…
Is aws ec2 instance private ip static or dynamic?
A private IPv4 address is an IP address that’s not reachable over the Internet. You can use private IPv4 addresses for communication between instances in the same VPC. When an instance is launched, aws allocate a primary private IPv4 address for the instance from selected or from default subnet and vpc. An instance receives a primary private IP address from…
Azure Backup Service in 5 minutes
The Azure Backup service provides simple, secure, and cost-effective solutions to back up your data and recover it from the Microsoft Azure cloud. Key Points: With Azure Backup service you can backup on-premise and cloud resources data. Azure Backup is Azure’s builtin backup service , which doesn’t require any infrastructure setup. Backup data’s are encrypted. You can easily backup and…