Step 1 - Installing Terraform (Linux)
Let's install Terraform
$ sudo su $ cd $ wget https://releases.hashicorp.com/terraform/0.13.3/terraform_0.13.3_linux_amd64.zip // download the latest available package $ unzip terraform_0.13.3_linux_amd64.zip $ rm -r terraform_0.13.3_linux_amd64.zip $ mkdir terraform_bin // create a folder named 'terraform' $ mv terraform downloads
Update your path so you can call Terraform binary from anywhere in the machine
$ nano ~/.profile
Add the following code at the end of the codeblock
To save the file and get back to the CLI, use
Ctrl + s then
Ctrl + x.
To update your path to the current session, use :
$ source ~/.profile
Terraform version to see if it was correctly installed and that we can call it from anywhere on the machine:
$ terraform --version
Let's finalize the installation of Terraform
Print a colon-separated list of locations in your
$ echo $PATH
Terraform binary to one of the listed locations. Here we use the following location:
$ mv terraform_bin/terraform /usr/local/bin
Terminal window, relaunch a new window (Ctrl + T)
Use the following commands to check if terraform was correctly installed and initialized:
$ sudo su $ terraform -help
Enable tab completion
If you use either bash or ssh you can enable tab completion for Terraform commands. To enable autocomplete, run the following command and then restart your shell.
$ terraform -install-autocomplete
Here we are! We are ready to use
Terraform for our
Infrastructure as Code projects on our local machine.
Step 2 - Configure AWS access to Terraform
Log into your
AWS account. If you don't have an account, create one: https://portal.aws.amazon.com/billing/signup#/start.
You can access your console after Signing Up to AWS using this link: https://console.aws.amazon.com/console/home.
Once logged into your
AWS console, go to
If you are new to AWS, please bypass all user configuration (green ticked marks below) for the sake of simplicity.
. Click on Users > Add user
. Next: permissions > Create group: call it admins_terraform.
. Filter policies: search for
AdministratorAccess in the search bar.
. Select the
AdministratorAccess policy and click on 'Create group'.
. Next: tags. Use as key: resources and as Value: terraform
. Next: review > create user > download the .csv file which contains security credentials for the user '
Access key ID and a
Secret access key were provided to you by
Be sure to keep these values in a secure location; you will use them in the next step.
You can keep this window opened and open a new
AWS console window from your browser.
Important Follow `AWS` security best practices by deleting this user and the group created after completing this gist, since all security parameters for this user weren't fulfilled for the sake of simplicity.
Step 3 - Install AWS CLI
$ sudo apt-get update
$ sudo apt install awscli
Once completed, check the installed version
$ aws --version
Let's configure our 'AWS ClI'.
$ aws configure
When prompted, enter 'AWS Access Key ID' provided upon user creation.
Do the same for 'Secret Access Key'.
Default region name: 'us-east-1'
Default output format: JSON
Step 4 - Install Atom and create Terraform's project workspace
We will use 'Atom' as our editor for building our Terraform project.
- Update the packages list and install the dependencies
$ sudo apt update $ sudo apt install software-properties-common apt-transport-https wget
- import the Atom Editor GPG key
$ wget -q https://packagecloud.io/AtomEditor/atom/gpgkey -O- | sudo apt-key add -
- enable the Atom APT repository
$ sudo add-apt-repository "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main"
- Install the latest version of Atom
$ sudo apt install atom
Once installed, Atom's icon should appear within your local applications.
Open the folder and launch Atom from this folder.
$ cd terraform $ atom .
The application should instantiate automatically and reffering to the folder terraform.
Before we create our workspace, we will install few packages.
Click on 'Install a package' > 'Open installer' and search for 'language-terraform' > Install the package.
Install also 'terraform-fmt' package.
If you go to Settings > packages, you'll see your newly installed packages.
Now that all prerequisites have been fulfilled, let's jump onto Create_Terraform_Workspace section of this gist.