Episode 2.1 : Getting Started With Terraform?

December 2, 2024 (1w ago)

Episode 2.1 : Getting Started With Terraform?

Hi there, It's Dilan 🤓!

In this second episode of the blog series, after what we saw on the previous episode we can now start our journey in the world of IaC with Terraform.

We will be seeing :


A brief intro into what's AWS

Amazon Web Service(AWS) logo

AWS is the most popular cloud infrastructure provider, and this by far. It provides a huge range of services tested throughout the time and famous for its security and performance from compute services like EC2 to AI service like Amazon Rekognition or SageMaker (as the name suggests, it's used to create "sage" 😂).

One of the other big advantages of AWS is that it provides a one-year free tier for you to test some of their products without you having to pay, but note that you need to have a bank card or at least use one.

There are tons of virtual card services out there so you don't have to go to a bank.


Now that we understand a bit what's AWS, you can go and create yourself an account there, the process is really straightforward, but if you are facing issues don't hesitate to leave a message here or to my DM!

Note: You will be required to set up a new user apart from the root user. This is a best practice to ensure the security and proper management of your AWS resources. Follow the AWS IAM guide to create a new user with administrative privileges.


A brief recap of what's Terraform

Terraform is an open-source tool created by HashiCorp and written in the Go Programming language. It is used to build, change, and version infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.

Terraform logo


Installing Terraform

To get started with Terraform, you need to install it on your local machine. Here are the instructions to follow for your operating system.

macOS

If you are using macOS, you can install Terraform using Homebrew:

brew tap hashicorp/tap
brew install hashicorp/tap/terraform

Windows

For Windows users, if you have Chocolatey installed, you can install Terraform by running:

choco install terraform

Always try checking the documentation too, you can find it here!

After installing Terraform, you can verify the installation by running:

terraform -help

This command should display the help text for Terraform, confirming that it is installed correctly.

Alternatively, you can download the executable files from the website, as shown in the image

Image of terraform downloaded as Zip file

If you do so you will need to add the PATH, and depending on your OS it might be slightly different.

Here you can find more on how to do it!


For Terraform to be able to make changes in your AWS account, you will need to set the AWS credentials for the IAM user you created earlier as the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

For example, here is how you can do it in a Unix/Linux/macOS terminal:

export AWS_ACCESS_KEY_ID=(your access key id)
export AWS_SECRET_ACCESS_KEY=(your secret access key)

And here is how you can do it in a Windows command terminal:

 set AWS_ACCESS_KEY_ID=(your access key id)
 set AWS_SECRET_ACCESS_KEY=(your secret access key)

Note that these environment variables apply only to the current shell, so if you reboot your computer or open a new terminal window, you’ll need to export these variables again. Also if you are wondering where to find them check here


How to deploy a single server


Let's deploy a single server here together!

How to deploy a configurable web server

Let's deploy a configurable server together!


How to deploy a cluster of web servers

Coming Soon: Stay tuned for the next 2.4 episode. 🚀


Deploying a load Balancer

Coming Soon: Stay tuned for the next 2.4 episode. 🚀


Conclusion

Coming Soon: Stay tuned for the next 2.X episode. 🚀



It was Dilan, GDGoC ( Google Developer Groups On Campus) Lead. See you soon! 👋