Terraform is a powerful Infrastructure as Code (IaC) tool that allows for efficient management and provisioning of infrastructure. Installing Terraform on AWS EC2 enables users to automate infrastructure setup directly on scalable cloud instances. This guide walks you through installing Terraform on AWS EC2 using Amazon Linux for a smooth and reliable setup. Whether you’re new to cloud automation or a DevOps engineer, installing Terraform on AWS EC2 is a critical step in streamlining 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:
Go to the EC2 Dashboard in the AWS Management Console.
β Check that your instance is running.
π 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)
Use the below command to connect via SSH:
ssh -i /path/to/your-key.pem ec2-user@your-instance-public-ip
Using PuTTY (Windows)
π» Download and install PuTTY.
Convert your
.pem
key to a.ppk
key using PuTTYgen (included with PuTTY).Open PuTTY and enter your EC2 instance’s public IP address in the Host Name field.
Under Connection > SSH > Auth, browse and select your
.ppk
file.Click Open to connect.
Using Mobaxterm (Windows)
π¦ Download and install Mobaxterm.
Select Session > SSH.
Enter your EC2 instance’s public IP address.
Provide the username (
ec2-user
) and browse for your.pem
key under the Advanced SSH settings.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! π¬
Devops Multi cloud Training
Choose the training style that fits your schedule β Self-Paced or Live Interactive Sessions. Both include hands-on projects, expert support, and lifetime access.
Feature | Self-Paced Training | Live Training |
---|---|---|
π― Mode | π₯Pre-Recorded Session | π§βπ«Live Class + Recordings |
πΌ Projects | π Weekend Real-Time Projects | π Weekdays + Weekend Real-Time Projects |
β Doubt Clearing | π Weekend Live Support Session | π§ Anytime Doubt Clearing Session |
π₯ Career Support & Mentorship | β No | β Yes |
π Global Certification Training | β No | β Yes |
π Access | βΎοΈ Lifetime Access | βΎοΈ Lifetime Access |
π° Fees | βΉ4,999 (2 x βΉ2,500) | βΉ7,999 (2 x βΉ4,000) |
βΉοΈ For More Info | Explore Self-Paced Training | Explore Live Training |