Fix: detect is_inactive drift when environment state changes outside Terraform#1088
Conversation
The is_inactive field (mapped to IsArchived in the API) was only being set from the API response in the importer, not in setEnvironmentSchema which is called during normal reads/refreshes. This meant terraform plan could not detect when an environment was re-activated from the UI.
RLRabinowitz
left a comment
There was a problem hiding this comment.
Just making sure - there's no drift when creating an environment without is_inactive at all, and then re-planning? Want to make sure it doesn't show is_inactive as it will be set to true all of a sudden
| return fmt.Errorf("schema resource data serialization failed: %w", err) | ||
| } | ||
|
|
||
| d.Set("is_inactive", false) |
There was a problem hiding this comment.
We probably need to remove the similar code from resource import
- Avoids panic when setEnvironmentSchema is called from data source (which doesn't have is_inactive in its schema) - Removes duplicate is_inactive code from the importer (Read is called after import anyway)
Done in 4a88880 — moved This also fixes a CI panic where
Verified against dev API — created environment without |
Summary
is_inactivefrom API response (IsArchived) during environment read/refresh, not just during importsetEnvironmentSchemaskippedIsArchived(taggedtfschema:"-") soterraform plancouldn't detect when an environment was activated/deactivated outside Terraform (e.g. from the UI)Fixes #1052
Test coverage -
is_inactivepermutationsis_inactive = falseis_inactive = trueis_inactive = trueis_inactive = falseis_inactive = falsefalse)is_inactive = truefalse)is_inactive = trueis_inactive = falsefalse)