In this workshop, we perform all command-line operations in the WSL2 (Windows Subsystem for Linux) environment instead of using Windows Command Prompt (CMD) or PowerShell. There are several key reasons for this choice:
Overall, WSL2 provides a more consistent and stable experience when working with cloud infrastructure tools, especially Terraform.
For macOS, you simply need to open the Terminal, and the user experience is almost identical to working in the WSL environment on Windows.
Before you begin, make sure the following tools are installed:
You can verify that all required tools have been installed successfully by running the following commands:
terraform version
aws --version
python3 --version



In the terminal, configure your AWS credentials so that AWS CLI can authenticate and execute commands throughout the deployment and testing process:
aws configure
Enter the following information when prompted:
AWS Access Key ID [None]: <ACCESS_KEY_ID>
AWS Secret Access Key [None]: <SECRET_ACCESS_KEY>
Default region name [None]: us-east-1
Default output format [None]:
After completing the configuration, restrict access to the credentials file so that only the current user can read it:
chmod 600 ~/.aws/credentials
Verify that the credentials are working correctly:
aws sts get-caller-identity
At the root directory of the project, create a new folder named terraform. This folder will contain Terraform files used to deploy AWS infrastructure.
Create a file named version.tf to specify the Terraform version, configure the connection to HCP Terraform, and define the AWS provider. Replace TEN-TO-CHUC with the name of your organization and replace TEN-WORKSPACE with the name of the workspace you created in HCP Terraform.
terraform {
required_version = ">= 1.5.0"
cloud {
organization = "TEN-TO-CHUC"
workspaces {
name = "TEN-WORKSPACE"
}
}
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.92"
}
# provider archive
archive = {
source = "hashicorp/archive"
version = "~> 2.4"
}
}
}
provider "aws" {
region = var.aws_region
default_tags {
tags = {
Project = "CloudCost-Insight"
ManageBy = "Terraform"
Environment = var.environment
}
}
}
In the WSL2 terminal, navigate to the directory containing the Terraform files, then run the following command to authenticate Terraform CLI with HCP Terraform:
terraform login




cd terraform
terraform init

After completing these steps, your working environment is fully configured and ready to deploy the CloudCost Insight system in the following sections.
.gitignoreSince this project is managed with Git and the source code will be pushed to GitHub, we need to configure Git to exclude files that should not be committed to the repository. This helps protect sensitive information and keeps the repository clean.
In the project’s root directory, create a .gitignore file with the following content:
# ===== Hugo =====
public/
.hugo_build.lock
# ===== System & IDE =====
.DS_Store
.vscode/
# ===== Terraform =====
.terraform/
*.tfstate
*.tfstate.*
*.tfvars
crash.log
.terraform/ directory: This is where Terraform stores the provider cache downloaded when running terraform init. Since this directory is large and can be recreated easily, it should not be committed to the repository.*.tfstate and *.tfstate.* files: These are Terraform state files that may contain sensitive information. Because this project uses HCP Terraform to manage the remote state, the infrastructure state is already stored centrally on HCP Terraform, so there is no need to keep local state files in the repository.*.tfvars files: These files contain actual variable values, such as the email address used for alert notifications, so they should not be committed to the repository to avoid exposing sensitive information. Only the template file, *.tfvars.example, should be included.