Complete the code to initialize a Terraform workspace in a monorepo setup.
terraform [1]The terraform init command initializes the working directory containing Terraform configuration files. This is the first step in any Terraform workflow, including monorepo setups.
Complete the code to apply Terraform changes only in a specific directory of a multi-repo setup.
terraform -chdir=[1] applyThe -chdir option tells Terraform to run commands in the specified directory. In a multi-repo setup, you apply changes in the directory containing the Terraform code, such as modules/network.
Fix the error in the Terraform backend configuration for a monorepo by completing the missing backend type.
terraform {
backend "[1]" {
bucket = "my-terraform-state"
region = "us-east-1"
}
}The backend type s3 configures Terraform to store state files in an AWS S3 bucket, which is common in monorepo setups for centralized state management.
Fill both blanks to define a Terraform workspace command and its purpose in a multi-repo environment.
terraform workspace [1] [2]
The command terraform workspace new dev creates a new workspace named 'dev'. Workspaces help manage multiple environments in a multi-repo setup.
Fill all three blanks to complete a Terraform command that plans changes for a specific workspace in a monorepo.
terraform workspace [1] && terraform plan -var-file=[2]/[3].tfvars
The command selects the 'prod' workspace and runs a plan using the variable file located in the 'envs' directory. This is typical in monorepo setups to isolate environment configurations.