Error: nil entry in ImportState results. This is always a bug with │ the resource that is being imported

Im using Terraform to integrate my AWS account, which has several environments, to a third party monitoring service, called Datadog, for this i have the AWS and Datadog providers, respectively, set up in terraform based in this documentation: Terraform Registry.

All is good, and I have been able to create the resources successfully in one of my workspaces.

The problem here is that, when i try to import a resource to the other workspaces, i get the error message:

│ Error: nil entry in ImportState results. This is always a bug with
│ the resource that is being imported. Please report this as
│ a bug to Terraform.

the resource that im trying to import is:
resource “datadog_integration_aws” “sandbox” {

account_id = local.envVar.AWS_ACCOUNTID
role_name = “DatadogAWSIntegrationRole”
}

Im trying to import it based in this documentation :
https://registry.terraform.io/providers/DataDog/datadog/latest/docs/resources/integration_aws#import

Using the command:
EXTERNAL_ID=cedc…40b terraform import datadog_integration_aws.sandbox 15…12:DatadogIntegrationRole

Being those my EXTERNAL_ID and AWS Account ID, respectively, and I have already verified this information, it is correct.

I have tried it all, searching, destroying and re-creating, The Hashicorp Community, deploying it in several ways, including contacting the Datadog team, they are helping me with that they are able to. However, I think this is something more related to terraform that Datadog, Since i am not able to import it.

Please help me as fast as you can.

Bear in mind this is a community forum of volunteers, not a helpdesk.

As an aside, it would usually be considered to be using Terraform incorrrectly, to create a resource in one workspace and then import the same resource in other workspaces. Any one resource should only be managed in one workspace. Otherwise, various resources my fight over changing the same resource. Use data sources to look up objects managed in other workspaces.

The error message has identified that there is a bug in the DataDog Terraform provider - you should believe it - because it’s correct. Looking in GitHub, it was fixed several months ago, even.

Thank you for your response, Maxb

In think that if you are managing resources in a workspace and therefore a tfstate, you should be able to import its configurations into other workspaces via their tfstate, as long as the resource block is written in both ones:

This can be done using the "terraform show " command, which shows all resources managed by a tfstate and therefore its workspace.

I think you are referring to this:

This issue was closed with no apparent fixings, if you have the fixings and/or workarounds for this, Could you please share them?

Aside of this, Personally, i had the opportunity to talk with the Datadog Team, all agreeing that this could in fact be a Terraform providers Issue, Quoting them:

" Looking at this error it seems to be related to this Terraform SDK provider error :
Terraform import. Error: nil entry in ImportState results · Issue #636 · integrations/terraform-provider-github · GitHub "
Specifically, it could possibly be a SDK version issue

Thus, this could be solved reaching out to this community and verifying the SDK Version functioning, Maybe with the Help of Hashicorp.

Last, but not less important, Im not ordering anyone to help me, im another volunteer asking for help.

You can… but now try to make any change to this resource… now you have to update every copy of the resource block effectively simultaneously, or they will fight with each other. This is why is I describe this as a usually incorrect usage.

The fix to your issue was in [datadog_integration_aws] Properly handle missing resource when importing by skarimo · Pull Request #1657 · DataDog/terraform-provider-datadog · GitHub