fbpx

πŸš€ Step-by-Step Guide: Installing Terraform on AWS EC2 Amazon Linux

Terraform is a powerful Infrastructure as Code (IaC) tool that allows for efficient management and provisioning of infrastructure. Setting up Terraform on an AWS EC2 Amazon Linux instance is a straightforward process. Follow this comprehensive guide to quickly install Terraform on your EC2 instance and start automating your infrastructure management.

βœ… Prerequisites

Before we begin, make sure you have the following:

  • πŸ—‚οΈ An AWS account

  • πŸ–₯️ An EC2 Amazon Linux instance up and running

  • πŸ”‘ SSH access to your instance using a key pair (PEM file)

  • πŸ“Ÿ A terminal or SSH client (like PuTTY, Mobaxterm, or an equivalent)

πŸ› οΈ Step 1: Setting Up an EC2 Instance

Ensure your EC2 instance is properly configured. Navigate to the AWS Management Console and follow these steps to verify your EC2 instance’s status:

  1. Go to the EC2 Dashboard in the AWS Management Console.

  2. βœ… Check that your instance is running.

  3. πŸ“‹ Copy the SSH Client Command of your instance, which will be required for SSH access.

πŸ”— Step 2: Connect to Your EC2 Instance

Using SSH (Linux/macOS)
  1. Use the below command to connect via SSH:

ssh -i /path/to/your-key.pem ec2-user@your-instance-public-ip

Using PuTTY (Windows)
  1. πŸ’» Download and install PuTTY.

  2. Convert your .pem key to a .ppk key using PuTTYgen (included with PuTTY).

  3. Open PuTTY and enter your EC2 instance’s public IP address in the Host Name field.

  4. Under Connection > SSH > Auth, browse and select your .ppk file.

  5. Click Open to connect.

Using Mobaxterm (Windows)
  1. πŸ“¦ Download and install Mobaxterm.

  2. Select Session > SSH.

  3. Enter your EC2 instance’s public IP address.

  4. Provide the username (ec2-user) and browse for your .pem key under the Advanced SSH settings.

  5. Click OK to start the SSH session.

πŸ”„ Step 3: Update the System

Ensure your system is up-to-date by running:

sudo yum update -y # For Amazon Linux

🧰 Step 4: Install yum-config-manager to Manage Your Repositories

Install the necessary dependencies using the appropriate command:

sudo yum install -y yum-utils

🌐 Step 5: Add the Official HashiCorp Linux Repository

Add the official HashiCorp Linux repository to your instance using yum-config-manager:

sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo

πŸ“¦ Step 6: Install Terraform from the New Repository

Install Terraform using yum:

sudo yum -y install terraform

Verify the installation:

terraform -v

You should see the installed version of Terraform.

πŸŽ‰ Conclusion

You have successfully installed Terraform on your AWS EC2 Amazon Linux instance. From here, you can start building and managing cloud infrastructure using Terraform.

If you have any questions or face issues, feel free to comment below! πŸ’¬

Leave a Comment

Your email address will not be published. Required fields are marked *

Open chat
Hello, Good day!!
How can we help you?