DEV Community

Robert Orozco
Robert Orozco

Posted on

DAY 7 - TERRAFORM

πŸ—‚οΈ Day 7 of the 30-Day Terraform Challenge β€” state isolation deep dive. Implemented both Terraform Workspaces and File Layout isolation for multi-environment deployments. Knowing when to use each one is what separates good infrastructure from great infrastructure. #30DayTerraformChallenge #TerraformChallenge #Terraform #IaC #DevOps #AWSUserGroupKenya #EveOps

LAB – PART 1
First, I created three workspaces named dev, staging and production.

Then, I switched to the dev workspace and ran terraform apply. The resource was successfully created.

Next, I switched to the staging workspace and executed terraform plan to validate the configuration.

The (EC2) resource was created successfully with instance type β€œt3.small”

Now, while working in the staging environment I’ll destroy the resource.

Only the web-staging machine was destroyed.

 

LAB – PART 2
ISOLATION VIA FILE LAYOUTS
First, I created bootstrap resources. S3 Resource to save the terraform.state of dev and production environment.

Next, I configure the backends files to set the parameter of the S3 name. I pushed terraform plan and terraform apply.

The resource terraform.tfstate was successfully created in S3.

Next, I pushed terraform apply to create the terraform.tfstate file for production environment.

Top comments (0)