Cyberithub

How to Install Terraspace on Linux Using 6 Easy Steps

Advertisements

In this article, I will take you through the steps to install terraspace on Linux Using 6 Easy Steps. Terraspace is a Terraform Framework that optimizes for infrastructure-as-code happiness. It provides an organized structure, conventions over configurations, keeps your code DRY, and adds convenient tooling. It brings some of the powerful features like use of Terrafile to centralize the modules and layering which enables same code to deploy and create multiple environments across multiple regions with just environment variables. Overall, it helps fill all the gaps left behind by terraform.

Some Important Features

  • It can keep your code dry by building your terraform project with common app and config/terraform structure which gets deployed in each deployment.
  • It has built-in generators to quickly create starter modules.
  • Features like Tfvars & Layering allow you to use the same code with different tfvars to create multiple environments.
  • It has the ability to deploy multiple stacks with a single command.
  • Terraspace provides built-in secrets support for AWS Secrets Manager, AWS SSM Parameter Store, Azure Key Vault, Google Secrets Manager.
  • The powerful feature of Terrafile helps centralize the management of modules.
  • It provides configurable CLI Hooks and CLI args to adjust the underlying terraform command.

How to Install Terraspace on Linux Using 6 Easy Steps

How to Install Terraspace on Linux Using 6 Easy Steps

Also Read: How to Install pacman package manager on Ubuntu 20.04 LTS (Focal Fossa)

Step 1: Prerequisites

a) You should have a running Linux(in our case it is Ubuntu 20.04 LTS) Server.

b) You should have sudo or root access to run privileged commands.

c) You should have apt utility available in your System.

 

Step 2: Update Your Server

In the first step, you need to update your package cache with all the latest available versions from Ubuntu repo by using sudo apt update command as shown below. If any of the packages needs to be upgraded then you can upgrade it by using sudo apt upgrade command as shown below.

cyberithub@ubuntu:~$ sudo apt update
[sudo] password for cyberithub:
Hit:1 https://download.docker.com/linux/ubuntu focal InRelease
Hit:2 https://dl.google.com/linux/chrome/deb stable InRelease
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:4 http://in.archive.ubuntu.com/ubuntu focal InRelease
Get:5 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:6 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Hit:7 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu focal InRelease
Fetched 336 kB in 3s (126 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done

If you are using any RHEL/CentOS based systems, then you can update the packages to the latest version by using yum update or dnf update command.

 

Step 3: Install Terraspace

There are multiple ways to install terraspace on a Linux system. You can choose any of the below method depending on the Linux distribution you are currently using.

a) Using RubyGems

The most common method used to install terraspace in a Linux system is through RubyGems. If you have RubyGems available in your system then you can install terraspace by using sudo gem install terraspace command as shown below.

cyberithub@ubuntu:~$ sudo gem install terraspace
Building native extensions. This could take a while...
Successfully installed eventmachine-1.2.7
Successfully installed eventmachine-tail-0.6.5
Successfully installed graph-2.10.0
Successfully installed rhcl-0.1.0
Successfully installed hcl_parser-0.2.2
Successfully installed tilt-2.0.11
Successfully installed render_me_pretty-0.8.4
Successfully installed jmespath-1.6.1
Successfully installed aws-partitions-1.631.0
Successfully installed aws-eventstream-1.2.0
Successfully installed aws-sigv4-1.5.1
Successfully installed aws-sdk-core-3.149.0
Successfully installed aws-sdk-kms-1.58.0
Successfully installed aws-sdk-s3-1.114.0
Successfully installed nokogiri-1.13.8-x86_64-linux
RubyZip 3.0 is coming!
**********************

The public API of some Rubyzip classes has been modernized to use named
parameters for optional arguments. Please check your usage of the
following classes:
* `Zip::File`
* `Zip::Entry`
* `Zip::InputStream`
* `Zip::OutputStream`

Please ensure that your Gemfiles and .gemspecs are suitably restrictive
to avoid an unexpected breakage when 3.0 is released (e.g. ~> 2.3.0).
See https://github.com/rubyzip/rubyzip for details. The Changelog also
lists other enhancements and bugfixes that have been implemented since
version 2.3.0.
........................................

b) Using apt-get

Since terraspace is not available by default from Ubuntu repo, you need to add the required repo by using echo "deb https://apt.boltops.com stable main" > /etc/apt/sources.list.d/boltops.list command as shown below.

cyberithub@ubuntu:~# echo "deb https://apt.boltops.com stable main" > /etc/apt/sources.list.d/boltops.list

Then you need to download the key to verify the integrity of the package using curl -s https://apt.boltops.com/boltops-key.public | apt-key add - command as shown below.

cyberithub@ubuntu:~# curl -s https://apt.boltops.com/boltops-key.public | apt-key add -
OK

To make system aware of the recently added repo, you need to run apt-get update command as shown below.

cyberithub@ubuntu:~# apt-get update
Hit:1 https://download.docker.com/linux/ubuntu focal InRelease
Hit:2 https://dl.google.com/linux/chrome/deb stable InRelease
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:4 http://in.archive.ubuntu.com/ubuntu focal InRelease
Hit:5 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu focal InRelease
Get:6 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:7 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [40.7 kB]
Get:8 https://apt.boltops.com stable InRelease [3,961 B]
Get:9 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [77.2 kB]
Get:10 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Get:11 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:12 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [278 kB]
Get:13 https://apt.boltops.com stable/main amd64 Packages [11.4 kB]
Get:14 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 DEP-11 Metadata [391 kB]
Get:15 http://in.archive.ubuntu.com/ubuntu focal-updates/multiverse i386 Packages [8,472 B]
Get:16 http://in.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [24.5 kB]
Get:17 http://in.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 DEP-11 Metadata [944 B]
Get:18 http://in.archive.ubuntu.com/ubuntu focal-backports/main amd64 DEP-11 Metadata [8,008 B]
Get:19 http://in.archive.ubuntu.com/ubuntu focal-backports/universe amd64 DEP-11 Metadata [30.5 kB]
Fetched 1,213 kB in 3s (416 kB/s)
Reading package lists... Done

Once repo is added, you can download and install terraspace package by using apt-get install -y terraspace command as shown below.

cyberithub@ubuntu:~# apt-get install -y terraspace
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
terraspace
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 37.7 MB of archives.
After this operation, 87.4 MB of additional disk space will be used.
Get:1 https://apt.boltops.com stable/main amd64 terraspace amd64 2.2.2-1 [37.7 MB]
Fetched 37.7 MB in 7s (5,048 kB/s)
Selecting previously unselected package terraspace.
(Reading database ... 251018 files and directories currently installed.)
Preparing to unpack .../terraspace_2.2.2-1_amd64.deb ...
You're about to install terraspace!
Unpacking terraspace (2.2.2-1) ...
Setting up terraspace (2.2.2-1) ...
Thank you for installing terraspace!

Terraspace has been installed. You can check by running:

terraspace version

You should see the terraspace version.
If you do not see this, it may be that /usr/local/bin is not in your PATH yet.
You can adjust ~/.bash_profile and add:

export PATH=/usr/local/bin:$PATH

And open a new terminal

c) Using Debian package

You also have the option to download the Debian package by using wget https://apt.boltops.com/packages/terraspace/terraspace-latest.deb command as shown below.

cyberithub@ubuntu:~$ wget https://apt.boltops.com/packages/terraspace/terraspace-latest.deb
--2022-09-18 19:12:08-- https://apt.boltops.com/packages/terraspace/terraspace-latest.deb
Resolving apt.boltops.com (apt.boltops.com)... 54.192.111.59, 54.192.111.129, 54.192.111.13, ...
Connecting to apt.boltops.com (apt.boltops.com)|54.192.111.59|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 37740964 (36M) [application/x-debian-package]
Saving to: ‘terraspace-latest.deb’

terraspace-latest.deb 100%[============================================================================>] 35.99M 4.32MB/s in 8.1s

2022-09-18 19:12:19 (4.45 MB/s) - ‘terraspace-latest.deb’ saved [37740964/37740964]

And, then install the package by using sudo dpkg -i terraspace-latest.deb command as shown below.

cyberithub@ubuntu:~$ sudo dpkg -i terraspace-latest.deb
Selecting previously unselected package terraspace.
(Reading database ... 251018 files and directories currently installed.)
Preparing to unpack terraspace-latest.deb ...
You're about to install terraspace!
Unpacking terraspace (2.2.2-1) ...
Setting up terraspace (2.2.2-1) ...
Thank you for installing terraspace!

Terraspace has been installed. You can check by running:

terraspace version

You should see the terraspace version.
If you do not see this, it may be that /usr/local/bin is not in your PATH yet.
You can adjust ~/.bash_profile and add:

export PATH=/usr/local/bin:$PATH

And open a new terminal

 

Step 4: Check Version

If you want to check terraspace version then you need to use terraspace version command as shown below.

cyberithub@ubuntu:~$ terraspace version
2.2.2

 

Step 5: Setup Check

To check the terraspace setup, you need to use terraspace setup check command as shown below.

cyberithub@ubuntu:~$ terraspace setup check
Detected Terraspace version: 2.2.2
Detected Terraform bin: /home/linuxbrew/.linuxbrew/bin/terraform
Detected Terraform v1.2.9
Terraspace requires Terraform v0.12.x and above
You're all set!

 

Step 6: Check all the available options

If you want to check all the options available with terraspace utility then you need to use terraspace --help command as shown below.

cyberithub@ubuntu:~$ terraspace --help
Usage: terraspace COMMAND [args]

The available commands are listed below.
The primary workflow commands are given first, followed by
less common or more advanced commands.

Main Commands:

terraspace all SUBCOMMAND # all subcommands
terraspace build [STACK] # Build project.
terraspace bundle # Bundle with Terrafile.
terraspace down STACK # Destroy infrastructure stack.
terraspace list # List stacks and modules.
terraspace new SUBCOMMAND # new subcommands
terraspace plan STACK # Plan stack.
terraspace seed STACK # Build starer seed tfvars file.
terraspace up STACK # Deploy infrastructure stack.
........................................

Leave a Comment