Terraform installation
Let's install Terraform on our ubuntu server: 
# Update and install gnupg, software-properties-common
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common
#Install the HashiCorp GPG key
wget -O- https://apt.releases.hashicorp.com/gpg | \
gpg --dearmor | \
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null
#Verify the key's fingerprint.
gpg --no-default-keyring \
--keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg \
--fingerprint
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
sudo apt update -y
# install terraform
sudo apt-get install terraform -yVerify the installation: 
 terraform -help- We have successfully installed terraform in our system. 
Add any subcommand to terraform -help to learn more about what it does and available options.
terraform -help planEnable tab completion :  👍
terraform -install-autocomplete
- Terraform has .tf extension file. 
a) Create a file main.tf then:
terraform initb) Format and validate the configuration:
terraform fmt #formatterraform validate #validatec) Then check the plan:
terraform pland) Now, apply the config
terraform apply 
# :? yes ; in case all configuration/plan is correct- Now check to the website. I installed nginx here. 

- If you also wanna try, check Install jenkins docker image with Terraform 
Last updated