databricks-cli/bundle/deploy/terraform
Ilia Babanov 153141d3ea
Don't fail while parsing outdated terraform state (#1404)
`terraform show -json` (`terraform.Show()`) fails if the state file
contains resources with fields that non longer conform to the provider
schemas.

This can happen when you deploy a bundle with one version of the CLI,
then updated the CLI to a version that uses different databricks
terraform provider, and try to run `bundle run` or `bundle summary`.
Those commands don't recreate local terraform state (only `terraform
apply` or `plan` do) and terraform itself fails while parsing it.
[Terraform
docs](https://developer.hashicorp.com/terraform/language/state#format)
point out that it's best to use `terraform show` after successful
`apply` or `plan`.

Here we parse the state ourselves. The state file format is internal to
terraform, but it's more stable than our resource schemas. We only parse
a subset of fields from the state, and only update ID and ModifiedStatus
of bundle resources in the `terraform.Load` mutator.
2024-05-01 08:22:35 +00:00
..
tfdyn Added support for job environments (#1379) 2024-04-22 11:44:34 +00:00
apply.go Return `diag.Diagnostics` from mutators (#1305) 2024-03-25 14:18:47 +00:00
convert.go Don't fail while parsing outdated terraform state (#1404) 2024-05-01 08:22:35 +00:00
convert_test.go Don't fail while parsing outdated terraform state (#1404) 2024-05-01 08:22:35 +00:00
destroy.go Return `diag.Diagnostics` from mutators (#1305) 2024-03-25 14:18:47 +00:00
dir.go Consolidate environment variable interaction (#747) 2023-09-11 08:18:43 +00:00
import.go Return `diag.Diagnostics` from mutators (#1305) 2024-03-25 14:18:47 +00:00
init.go Add docker images for the CLI (#1353) 2024-04-12 15:22:30 +00:00
init_test.go Update `testutil` helpers to return path (#1383) 2024-04-19 15:05:36 +00:00
interpolate.go Return `diag.Diagnostics` from mutators (#1305) 2024-03-25 14:18:47 +00:00
interpolate_test.go Return `diag.Diagnostics` from mutators (#1305) 2024-03-25 14:18:47 +00:00
load.go Don't fail while parsing outdated terraform state (#1404) 2024-05-01 08:22:35 +00:00
load_test.go Move path field to bundle type (#1316) 2024-03-27 09:03:24 +00:00
pkg.go Followup improvements to the Docker setup script (#1369) 2024-04-18 20:52:11 +00:00
pkg_test.go Followup improvements to the Docker setup script (#1369) 2024-04-18 20:52:11 +00:00
plan.go Return `diag.Diagnostics` from mutators (#1305) 2024-03-25 14:18:47 +00:00
state_pull.go Return `diag.Diagnostics` from mutators (#1305) 2024-03-25 14:18:47 +00:00
state_pull_test.go Move path field to bundle type (#1316) 2024-03-27 09:03:24 +00:00
state_push.go Return `diag.Diagnostics` from mutators (#1305) 2024-03-25 14:18:47 +00:00
state_push_test.go Move path field to bundle type (#1316) 2024-03-27 09:03:24 +00:00
state_test.go Added deployment state for bundles (#1267) 2024-03-18 14:41:58 +00:00
unbind.go Return `diag.Diagnostics` from mutators (#1305) 2024-03-25 14:18:47 +00:00
util.go Don't fail while parsing outdated terraform state (#1404) 2024-05-01 08:22:35 +00:00
util_test.go Don't fail while parsing outdated terraform state (#1404) 2024-05-01 08:22:35 +00:00
write.go Return `diag.Diagnostics` from mutators (#1305) 2024-03-25 14:18:47 +00:00