Dear Readers,
In this article, we will see the following Install Terraform in Amazon EC2 Instance.
Steps to Follow :
- Logging to AWS Account
- Launch Linux Server
- Connect to Linux EC2 Instance by Using Putty
- Download and Install Terraform
- Set the path for terraform
- Start the terraform
1. Logging to AWS Account
First, we need to AWS Console page by using the below link.
https://aws.amazon.com/console/
Click on the sign in to Console button.
Logging to AWS account
Login using username & password and click on sign in.
Enter to AWS Management Console
We can see the AWS Management Console Dashboard.
Go to Services, under the compute module click EC2 service to open.
2. Launch Linux EC2 Instance
Go to Services, under the compute module click EC2 service to open.
We can launch Linux EC2 Instance by using below link.
How to Launch Linux EC2 Instance
We can see the Linux server has been launched successfully.
3. Connect to Linux EC2 Instance Using Putty
We can connect putty by using the below link.
Connect to EC2 Instance Using Putty
Go inside the Linux Server Terminal.
1 2 3 4 5 6 7 8 9 10 |
login as: ec2-user Authenticating with public key "imported-openssh-key" Last login: Thu Oct 22 02:26:51 2020 from 106.217.132.120 __| __|_ ) _| ( / Amazon Linux 2 AMI ___|\___|___| https://aws.amazon.com/amazon-linux-2/ [ec2-user@ip-172-31-11-86 ~]$ |
4. Download and Install Terraform
First, we need to Terraform official website by using below link.
https://www.terraform.io/downloads.html
Select Linux 64-bit and copy the link address.
Go inside the Linux Server Terminal.
1 2 3 4 5 6 7 8 9 10 |
login as: ec2-user Authenticating with public key "imported-openssh-key" Last login: Thu Oct 22 02:26:51 2020 from 106.217.132.120 __| __|_ ) _| ( / Amazon Linux 2 AMI ___|\___|___| https://aws.amazon.com/amazon-linux-2/ [ec2-user@ip-172-31-11-86 ~]$ |
Download Terraform package
1 2 3 4 5 6 7 8 9 10 11 |
[ec2-user@ip-172-31-11-86 ~]$ wget https://releases.hashicorp.com/terraform/0.13.5/terraform_0.13.5_linux_amd64.zip --2020-10-24 11:36:50-- https://releases.hashicorp.com/terraform/0.13.5/terraform_0.13.5_linux_amd64.zip Resolving releases.hashicorp.com (releases.hashicorp.com)... 151.101.153.183, 2a04:4e42:24::439 Connecting to releases.hashicorp.com (releases.hashicorp.com)|151.101.153.183|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 34880173 (33M) [application/zip] Saving to: ‘terraform_0.13.5_linux_amd64.zip’ 100%[==============================================================================================================================>] 34,880,173 105MB/s in 0.3s 2020-10-24 11:36:51 (105 MB/s) - ‘terraform_0.13.5_linux_amd64.zip’ saved [34880173/34880173] |
Verify Terraform package
we can see the terraform zip file which was downloaded.
1 2 3 |
[ec2-user@ip-172-31-11-86 ~]$ ll total 34064 -rw-rw-r-- 1 ec2-user ec2-user 34880173 Oct 21 19:33 terraform_0.13.5_linux_amd64.zip |
Unzip Terraform package
1 2 3 |
[ec2-user@ip-172-31-11-86 ~]$ unzip terraform_0.13.5_linux_amd64.zip Archive: terraform_0.13.5_linux_amd64.zip inflating: terraform |
We can see the terraform binary file
1 2 3 4 |
[ec2-user@ip-172-31-11-86 ~]$ ll total 117608 -rwxr-xr-x 1 ec2-user ec2-user 85545059 Oct 21 18:50 terraform -rw-rw-r-- 1 ec2-user ec2-user 34880173 Oct 21 19:33 terraform_0.13.5_linux_amd64.zip |
Install terraform
we execute the binary file for installing terraform
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
[ec2-user@ip-172-31-11-86 ~]$ ./terraform Usage: terraform [-version] [-help] <command> [args] The available commands for execution are listed below. The most common, useful commands are shown first, followed by less common or more advanced commands. If you're just getting started with Terraform, stick with the common commands. For the other commands, please read the help and docs before usage. Common commands: apply Builds or changes infrastructure console Interactive console for Terraform interpolations destroy Destroy Terraform-managed infrastructure env Workspace management fmt Rewrites config files to canonical format get Download and install modules for the configuration graph Create a visual graph of Terraform resources import Import existing infrastructure into Terraform init Initialize a Terraform working directory login Obtain and save credentials for a remote host logout Remove locally-stored credentials for a remote host output Read an output from a state file plan Generate and show an execution plan providers Prints a tree of the providers used in the configuration refresh Update local state file against real resources show Inspect Terraform state or plan taint Manually mark a resource for recreation untaint Manually unmark a resource as tainted validate Validates the Terraform files version Prints the Terraform version workspace Workspace management All other commands: 0.12upgrade Rewrites pre-0.12 module source code for v0.12 0.13upgrade Rewrites pre-0.13 module source code for v0.13 debug Debug output management (experimental) force-unlock Manually unlock the terraform state push Obsolete command for Terraform Enterprise legacy (v1) state Advanced state management |
Verify the version of terraform
1 2 3 |
[ec2-user@ip-172-31-11-86 ~]$ terraform --version Terraform v0.13.5 + provider registry.terraform.io/hashicorp/aws v3.12.0 |
5. Set the Path for terraform
1 2 3 4 |
[ec2-user@ip-172-31-11-86 ~]$ pwd /home/ec2-user [ec2-user@ip-172-31-11-86 ~]$ echo $"export PATH=\$PATH:$(pwd)" >> ~/.bash_profile [ec2-user@ip-172-31-11-86 ~]$ source ~/.bash_profile |
6. Start the terraform
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
[ec2-user@ip-172-31-11-86 ~]$ terraform Usage: terraform [-version] [-help] <command> [args] The available commands for execution are listed below. The most common, useful commands are shown first, followed by less common or more advanced commands. If you're just getting started with Terraform, stick with the common commands. For the other commands, please read the help and docs before usage. Common commands: apply Builds or changes infrastructure console Interactive console for Terraform interpolations destroy Destroy Terraform-managed infrastructure env Workspace management fmt Rewrites config files to canonical format get Download and install modules for the configuration graph Create a visual graph of Terraform resources import Import existing infrastructure into Terraform init Initialize a Terraform working directory login Obtain and save credentials for a remote host logout Remove locally-stored credentials for a remote host output Read an output from a state file plan Generate and show an execution plan providers Prints a tree of the providers used in the configuration refresh Update local state file against real resources show Inspect Terraform state or plan taint Manually mark a resource for recreation untaint Manually unmark a resource as tainted validate Validates the Terraform files version Prints the Terraform version workspace Workspace management All other commands: 0.12upgrade Rewrites pre-0.12 module source code for v0.12 0.13upgrade Rewrites pre-0.13 module source code for v0.13 debug Debug output management (experimental) force-unlock Manually unlock the terraform state push Obsolete command for Terraform Enterprise legacy (v1) state Advanced state management |
Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates
KTEXPERTS is always active on below social media platforms.
Facebook : https://www.facebook.com/ktexperts/
LinkedIn : https://www.linkedin.com/company/ktexperts/
Twitter : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts