Building your first Terraform template
We have created our AWS account and an IAM user and set up the necessary credentials for Terraform and the AWS CLI to communicate with AWS to provision infrastructure. Let’s now start developing our first Terraform template.
A dedicated working directory is required for each Terraform configuration. To begin with, create a new directory for your first Terraform project. Any code editor or terminal can be used for this purpose, and we will provide the terminal commands for your convenience:
mkdir my-first-terraform-project
Change into the directory so that we can start to create files in it:
cd my-first-terraform-project
Create an empty file to define your infrastructure:
touch main.tf
Open the main.tf
file in your preferred text editor and copy the following configuration into the file. Save the file once you have added the configuration:
terraform { required_providers { aws = { ...