tabular-io / terraform-provider-tabular

Mozilla Public License 2.0
3 stars 1 forks source link

Error: Could not fetch database in warehouse after manually deleting database and statefiles #41

Closed parejadan closed 3 weeks ago

parejadan commented 3 weeks ago

Problem

When using the tabular_database resource in the following way:

resource "tabular_database" "this" {
  count = var.create ? 1 : 0

  name = var.name
  warehouse_id = var.warehouse_id
}

We get the following Error:

│ Could not fetch database <manually-deleted-database-id> in warehouse
│ <warehouse-id-redacted>: 404 Not Found

Provider Information

Initializing provider plugins...
- Finding tabular-io/tabular versions matching "~> 0.0.23"...
- Installing tabular-io/tabular v0.0.25...
- Installed tabular-io/tabular v0.0.25 (self-signed, key ID 9AA3BCF3BEF680C8)

Why Database was Manually Deleted

The databases this error surfaced for got manually created prior to terraform being introduced for producing them on tabular. When terraform was eventually introduced, the databases were manually deleted, then recreated using terraform without problems.

We then had a situation that resulted in manual deletion again. We considered that this wouldn't cause any problem as typically, when an AWS resource is manually deleted outside the terraform API, even though statefiles consider that the resource exist, terraform provider for AWS attempts to recreate the resource.

Testing

  1. This issue surfaces during terraform plan
  2. We attempted to resolve the situation considering that the plan might require statefiles to get refreshed from an apply. However, it seems like the apply still expects the databases to exist. When it determines they don't exist, they do not attempt to recreate the databases (like an AWS provider would for it's resources).
  3. We then attempted to remove the statefiles to emulate the first time these databases got created using terraform, but the issue persists.

Given that statefiles are no longer at play, and this same exact issue persists, we are considering there's a problem or some cache in tabular/provider we're unable to clear out.

Expectation

Regardless of cache, we'd consider it standard behavior for a provider to recreate a resource that no longer exists.

maxwell-gobel commented 3 weeks ago

Fixed by #42.