ibm-cloud-docs / schematics

schematics
Other
1 stars 10 forks source link

Anomalous behaviour of `schematics.tfvars` in schematics workspaces #19

Closed S-Mann closed 1 year ago

S-Mann commented 1 year ago

I am trying to use schematics workspaces for my IaC. I want to use it to wrap over terraform and let schematics perform the plan generation, management and application.

Client related information

ibmcloud ibmcloud version 2.17.1+5dece51-2023-06-23T17:17:15+00:00 schematics[sch] 1.12.10

Current behaviour

Note: Make sure a brand new workspace is created Follow these steps:

  1. Update workspace with your terraform code. ibmcloud schematics workspace upload --id $WORKSPACE_ID --file wks.tar --template $TEMPLATE_ID
  2. Generate terraform plan using a var-file. ibmcloud schematics plan --id $WORKSPACE_ID --var-file terraform.tfvars.json (notice I am using a JSON file as the tfvar file that schematics accepts is only key value, but JSON allows complex objects and list)
  3. Apply plan using the same var-file. ibmcloud schematics apply --id $WORKSPACE_ID --var-file terraform.tfvars.json. This step will FAIL
    
    Error: Invalid argument name

on schematics.tfvars line 53: 53: xxxhiddenxxx

Argument names must not be quoted.


# Expected behaviour

Same as above but all steps PASS

# Observation

- I noticed that the variables in the `schematics.tfvars` isn't getting purged completely, meaning the old variables still exist in the workspace causing **WARNINGS** from terraform. Ideally the `schematics.tfvars` should be completely purged and new values from the `var-file` parameter should be used.

Warning: Value for undeclared variable

The root module does not declare a variable named "some_old_variable" but a value was found in file "schematics.tfvars". If you meant to use this value, add a "variable" block to the configuration.

To silence these warnings, use TFVAR... environment variables to provide certain "global" settings to all configurations in your organization. To reduce the verbosity of these warnings, use the -compact-warnings option.


- I am suspecting the `xxxhiddenxxx` issue is due to the same reason of `schematics.tfvar` not getting purged and re-written with new values because when I retry this same process at step-1 the variables already have an override value from the earlier `var-file` this is highly undesirable.
- And when I do the above process and not specify a `var-file` both the plan and apply work perfectly fine but with old variable overrides. 
S-Mann commented 1 year ago

Moved to internal issues.