Skip to content

Instantly share code, notes, and snippets.

@rajivmehtaflex
Created September 18, 2024 08:53
Show Gist options
  • Save rajivmehtaflex/ad4b89a1a0692cef1824b2053ab6516a to your computer and use it in GitHub Desktop.
Save rajivmehtaflex/ad4b89a1a0692cef1824b2053ab6516a to your computer and use it in GitHub Desktop.
terraform installation script
#!/bin/bash
# install_terraform.sh
# Exit immediately if a command exits with a non-zero status
set -e
# Update the package index
echo "Updating package index..."
sudo apt-get update
# Install required packages
echo "Installing required packages..."
sudo apt-get install -y gnupg software-properties-common
# Add the HashiCorp GPG key
echo "Adding HashiCorp GPG key..."
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg >/dev/null
# Add the official HashiCorp repository
echo "Adding HashiCorp repository..."
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
# Update the package index again
echo "Updating package index..."
sudo apt-get update
# Install Terraform
echo "Installing Terraform..."
sudo apt-get install -y terraform
# Verify Terraform installation
echo "Verifying Terraform installation..."
terraform --version
echo "Terraform installation complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment