You have heard of the benefit of Infrastructure as Code (IaC). You have seen the power, speed, and other beautiful features as well as the benefits of automation in provisioning your resources. You may now wonder, how can I setup my local machine to use this newfound tool and start deploying servers, databases, networking components, storage and the likes. This step-by-step guide would assist you in setting up Terraform, AWS CLI - which is the Command Line Interface to access your Amazon Web Services resource and VS Code - Visual Studio Code, a popular code editor. These tools can be installed on various operating system such as Linux, Mac, and Windows. Let us start with Terraform installation on Windows.
Terraform
- Go to terraform.io
- Click on Download Terraform
- Go to the section for Windows
Click on the Download. Check if your computer is AMD64 or 386
A terraform.exe file would be downloaded in a zip file format that you have to unzip.
- Go to your downloaded unzipped file
- Copy the .exe file to the C drive and place it in a new folder named terraform.
- Search for the Advanced System Settings.
- Click on the Environment Variables
- In the bottom section named System variables, scroll down to click on Path
Click on Edit
The click on New
Type in the path ex., C:\terraform
Click on OK
To check your installation, you can open your command line and type terraform version. You should see a version installed on the machine.
AWS CLI
To efficiently use the AWS CLI to communicate with AWS resources, you will need to sign up for an AWS account. You can sign up for a free account with your credit card on aws.amazon.com
After registering the account, you will have access to all resources on the AWS console. Best practice requires that you create an IAM user with administrative permissions that can be used subsequently to create other users.
Here are the steps to create an IAM admin user on the AWS Console.
- Seach for IAM in the search bar of the console
- Click on IAM
- In the left pane under Access management, click on Users
- Click on Create user
- Type the user name
Note: Since we will be using the CLI, we left the box unchecked.
- Click on next to set permissions. Best practice is to create a group and attach policies to that group. However, since we are dealing with a user, we will click Attach policies directly. Then click on AdministratorAccess
- Review the details and click on Create user
- To generate the Access Keys needed for CLI access, click on the newly created terraform-user
- Click on the Security credentials tab
- Scroll down to the Access keys section and click on create access key
- Select Command Line Interface for your use case
- Click on the confirmation then click Next
- You may wish to add tags, thereafter, click on Create access key
- Keep your access key safe. You may choose to download the .csv file then click Done
Next let us install the AWS CLI version 2 on our machine.
Go to the AWS documentation page at https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
Select the installation guide for Windows and follow the installer wizard
After installation, in your command prompt, you can run the aws --version
- You can configure the CLI with the Access key credentials we generated. Run the command aws configure and enter the access key, secret access key, region and the default output format
VS Code
Now that we have configured our CLI, let us install VS Code.
Download Visual Studio Code at https://code.visualstudio.com/download
Follow the installer wizard instructions.
After installation and launching VS Code, click on Extensions in the left side pane and search for AWS Toolkit
- Click on the Install button under the AWS Toolkit
You are now ready to use all these tools in your learning of Terraform. In the next post, we will start deploying infrastructure with Terraform.
Top comments (0)