advanced-terraform-2823489 icon indicating copy to clipboard operation
advanced-terraform-2823489 copied to clipboard

Multiple Environment Configuration command has changed

Open pau1ie opened this issue 3 years ago • 0 comments

Issue Overview

Terraform has changed since the course was written such that the terraform init command described in section 03_05-06_multi_environment no longer works.

Describe your environment

Following the course exactly

Steps to Reproduce

  1. Clone this repo
  2. cd advanced-terraform-course/03_05-06_multi_environment/environments/0_development
  3. terraform init ../../manifests

Expected Behavior

Terraform init completes

Current Behavior

Error: Too many command line arguments. Did you mean to use -chdir?

Possible Solution

Run the following command instead for the init

TF_DATA_DIR="$PWD/.terraform" terraform  -chdir=../../manifests/ init

The variables still need to be read from the current directory during plan and (presumably) apply, so we need to do something like the following:

 TF_DATA_DIR="$PWD/.terraform" terraform  -chdir=../../manifests/ plan \
    -var-file="$PWD/development.auto.tfvars" -out=s1.tfplan 

This is still not quite the same as suggested as it leaves the .terraform.lock.hcl file in the manifests directory. I don't know enough to know whether this is a problem that needs to be fixed.

See the terraform release notes for more information.

pau1ie avatar Sep 02 '22 16:09 pau1ie