Skip to content

Latest commit

 

History

History
265 lines (178 loc) · 6.87 KB

prerequisites.md

File metadata and controls

265 lines (178 loc) · 6.87 KB

Prerequisites

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
🔵 See output

isaac-arnault-terraform-5.png

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

export PATH="$PATH:~/terraform"
🔴 See hint

isaac-arnault-terraform-6.png

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

Let's check Terraform version to see if it was correctly installed and that we can call it from anywhere on the machine:

$ terraform --version
🔵 See output

isaac-arnault-terraform-7.png

Let's finalize the installation of Terraform
Print a colon-separated list of locations in your PATH.

$ echo $PATH

Move the Terraform binary to one of the listed locations. Here we use the following location: usr/local/bin.

$ mv terraform_bin/terraform /usr/local/bin

Close your 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
🔴 See hint

isaac-arnault-terraform-8.png

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 IAM.
If you are new to AWS, please bypass all user configuration (green ticked marks below) for the sake of simplicity.

🔵 See output

isaac-arnault-aws-1.png

. 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'.

🔵 See output

isaac-arnault-aws-3.png

. 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 ' terraform_user'

Access key ID and a Secret access key were provided to you by AWS.

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

🔵 See output

isaac-arnault-terraform1.png

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.

  1. Update the packages list and install the dependencies
$ sudo apt update
$ sudo apt install software-properties-common apt-transport-https wget
  1. import the Atom Editor GPG key
$ wget -q https://packagecloud.io/AtomEditor/atom/gpgkey -O- | sudo apt-key add -
  1. enable the Atom APT repository
$ sudo add-apt-repository "deb [arch=amd64] https://packagecloud.io/AtomEditor/atom/any/ any main"
  1. Install the latest version of Atom
$ sudo apt install atom

Once installed, Atom's icon should appear within your local applications.

🔵 See output

isaac-arnaul-terraform-2.jpg

Open the folder and launch Atom from this folder.

$ cd terraform
$ atom .
🔵 See output

isaac-arnault-terraform-5.jpg

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.

🔵 See output

isaac-arnault-terraform-6.jpg

Install also 'terraform-fmt' package.

🔵 See output

isaac-arnault-terraform-7.jpg

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.