Hey folks I have custom terraform provider (wirtte...
# package-authoring
d
Hey folks I have custom terraform provider (wirtten with TF plugin framework) and Pulumi provider for it.
Copy code
<http://github.com/pulumi/pulumi-terraform-bridge/pf|github.com/pulumi/pulumi-terraform-bridge/pf> v0.23.0
	<http://github.com/pulumi/pulumi-terraform-bridge/v3|github.com/pulumi/pulumi-terraform-bridge/v3> v3.70.0
The issues I see: when read handler does
resp.State.RemoveResource(ctx)
which is suggested way by the tf We are getting Pulumi error:
Copy code
custom:index:Resource (name):
         error: Expected an Object, got: {<nil>}
@enough-garden-22763 Any thoughts^?
I checked what remove resource does:
Copy code
// RemoveResource removes the entire resource from state.
//
// If a Resource type Delete method is completed without error, this is
// automatically called on the DeleteResourceResponse.State.
func (s *State) RemoveResource(ctx context.Context) {
	s.Raw = tftypes.NewValue(s.Schema.Type().TerraformType(ctx), nil)
}
So TF sets states to null on purpose. Are there anything we need to do of Pulumi side to recover?
We do refresh before every run but it doesn't help
So did some digging. For some reason refresh throws the error even with the fact that terraform able to handle it gracefully.
Copy code
Type                         Name                        Plan        Info
     pulumi:pulumi:Stack                aaa-test              1 error
     ├─ pulumi:providers:isc           provider
 ~   ├─ custom:index:Resource          v2                          update      [diff: +csId,size,state,storageType]
 ~   ├─ custom:index:Resource          v1                          update      [diff: +csId,size,state,storageType]
 ~   └─ custom:index:Resource2          a-machine           refresh     1 error

Diagnostics:
  custom:index:Resource (a-machine):
    error: Preview failed: Expected an Object, got: {<nil>}

  pulumi:pulumi:Stack (aaa-test):
    error: preview failed
e
Hi Andrii! This is not great, good indication that this is a bug in the bridge if TF handles it, could you post a repro in pulumi-terraform-bridge issue tracker? That'd help a lot!
d
tf:
Copy code
Note: Objects have changed outside of Terraform

Terraform detected the following changes made outside of Terraform since the last "terraform apply" which may have affected
this plan:

  # custom.resource has been deleted
  - resource "custom" "test" {
      - id                         = "66313bea79d7fd77baf929e5" -> null
        name                       = "66313bea79d7fd77baf929e5"
        tags                       = {}
        # (26 unchanged attributes hidden)
    }


Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the
following plan may include actions to undo or respond to these changes.

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:
  + create

Terraform will perform the following actions:

  # custom.test will be created
  + resource "custom" "test" {
      + account_id                 = (known after apply)
      + action                     = (known after apply)
@enough-garden-22763 sure
I'll do it.
e
Perfect thank you!
d
Ty
e
Excellent!