cloudfoundry-community/terraform-provider-cloudfoundry

Can't import resources

yryzhan-vitech opened this issue · 3 comments

After importing resources to the:

  • cloudfoundry_user_provided_service
  • cloudfoundry_service_key
    we've received the next error:


│ Error: The provider returned a resource missing an identifier during ImportResourceState. This is generally a bug in the resource implementation for import. Resource import code should not call d.SetId("") or create an empty ResourceData. If the resource is missing, instead return an error. Please report this to the provider developers.


I'm having the same error:

$ terraform import 'cloudfoundry_user_provided_service.this' 038baf6d-b4ab-4e1e-adfb-6c57b6546e92
data.cloudfoundry_org.this: Reading...
data.cloudfoundry_domain.this: Reading...
data.cloudfoundry_asg.this: Reading...

...

Error: The provider returned a resource missing an identifier during ImportResourceState. This is generally a bug in the resource implementation for import. Resource import code should not call d.SetId("") or create an empty ResourceData. If the resource is missing, instead return an error. Please report this to the provider developers.

I can replicate this issue with the testcase TestAccUserProvidedService_importBasic

Running pre-hook...
Finished running pre-hook.
=== RUN   TestAccUserProvidedService_importBasic
    import_cf_user_provided_service_test.go:12: Step 2/2 error running import: exit status 1

        Error: The provider returned a resource missing an identifier during ImportResourceState. This is generally a bug in the resource implementation for import. Resource import code should not call d.SetId("") or create an empty ResourceData. If the resource is missing, instead return an error. Please report this to the provider developers.


--- FAIL: TestAccUserProvidedService_importBasic (39.25s)
FAIL
Running post-hook...
Finished running post-hook.
FAIL    github.com/terraform-providers/terraform-provider-cloudfoundry/cloudfoundry     42.894s
FAIL

I created this PR to fix this issue:
#471