Description: Here I have explained, How to install Terraform in Centos and How to create an EC2 instance using Terraform
Install Terraform in Centos
- Download Terraform from the URL and upload to Centos machine or download using wget command
- Once you download unzip and extract it
- After extract terraform binary from zipping, We need to add it on bin path or add the binary path to the source
OR
Add current pwd path to bash_profile using below command
# echo $"export PATH=\$PATH:$(pwd)" >> ~/.bash_profile
# source ~/.bash_profile
- After adding into path verify terraform version using below command
Create EC2 instance using Terraform
- Create IAM user with EC2 access in AWS console
- Download CSV for access_key and secret_key for user
- Create Project Directory for Terraform
# cd Terraform-Project
- Create terraform project as follow and paste
# vi ec2.tf provider "aws" { access_key = "XXXXXXXXXXXX" secret_key = "XXXXXXXXXXXXXXX" region = "us-east-1" } resource "aws_instance" "Test" { ami = "ami-09d19e919d57453f8" instance_type = "t2.micro"key_name = "Terraform_Key"tags = { Name = "Terraform" }}
- Initialize terraform project by run below command, you will get output as follow
- After initialize apply to terraform project using the below command and you will get output as follow. We need to type 'yes' to confirm
No comments:
Post a Comment