cloudflare / terraform-provider-cloudflare

Cloudflare Terraform Provider
https://registry.terraform.io/providers/cloudflare/cloudflare
Mozilla Public License 2.0
736 stars 555 forks source link

│ 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. #3394

Open Pravallika1995 opened 2 weeks ago

Pravallika1995 commented 2 weeks ago

Confirmation

Terraform and Cloudflare provider version

We are using the latest providers

Affected resource(s)

cloudflare_access_application import doesnt wotk with zone_id instead of account_id

Terraform configuration files

import {
  id = "zone/1234/1234"
  to = module.cloudflare_access_application_aiq_service.example
}

resource "cloudflare_access_application" "access_application" {
  zone_id                   = var.zone_id
  name                      = test
  domain                    = hostname
  type                      = "self_hosted"
  session_duration          = "24h"
  auto_redirect_to_identity = true
  allowed_idps              = ["123"]
}

Link to debug output

none

Panic output

No response

Expected output

Import to the resource should work but failed

Actual output

│ 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.

Steps to reproduce

Create a cloudflare access application with zone_id. Now try to import using terraform import command. As per the documention command should be: $ terraform import cloudflare_access_application.example /

Since we are using zone_id we should replace account_id with zone_id: $ terraform import cloudflare_access_application.example / But this failed with some error saying: ##[error]Script failed with exit code: 1

So tried like : $ terraform import cloudflare_access_application.example zone// This also failed with: │ 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.

Additional factoids

No response

References

No response

github-actions[bot] commented 2 weeks ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

github-actions[bot] commented 2 weeks ago

Thank you for reporting this issue! For maintainers to dig into issues it is required that all issues include the entirety of TF_LOG=DEBUG output to be provided. The only parts that should be redacted are your user credentials in the X-Auth-Key, X-Auth-Email and Authorization HTTP headers. Details such as zone or account identifiers are not considered sensitive but can be redacted if you are very cautious. This log file provides additional context from Terraform, the provider and the Cloudflare API that helps in debugging issues. Without it, maintainers are very limited in what they can do and may hamper diagnosis efforts.

This issue has been marked with triage/needs-information and is unlikely to receive maintainer attention until the log file is provided making this a complete bug report.

Pravallika1995 commented 2 weeks ago

2024-06-25T10:07:32.518Z [DEBUG] Resource instance state not found for node "module.cloudflare_access_application_aiq_service.cloudflare_access_application.access_application", instance module.cloudflare_access_application_aiq_service.cloudflare_access_application.access_application 2024-06-25T10:07:32.518Z [DEBUG] ReferenceTransformer: "module.cloudflare_access_application_aiq_service.cloudflare_access_application.access_application" references: [] 2024-06-25T10:07:32.519Z [DEBUG] provider.terraform-provider-cloudflare_v4.11.0: Importing Cloudflare Access Application: id XXXXXX/XXXXXX for account zone: @caller=github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_access_application.go:248 tf_provider_addr=registry.terraform.io/cloudflare/cloudflare tf_rpc=ImportResourceState @module=cloudflare tf_mux_provider=tf5to6server.v5tov6Server tf_req_id=13825959-ff0e-1460-47bf-1dfbc89607cc tf_resource_type=cloudflare_access_application timestamp=2024-06-25T10:07:32.518Z 2024-06-25T10:07:32.519Z [DEBUG] provider.terraform-provider-cloudflare_v4.11.0: 2024/06/25 10:07:32 2024-06-25T10:07:32.519Z [DEBUG] provider.terraform-provider-cloudflare_v4.11.0: GET /client/v4/accounts/zone/access/apps/XXXXXX/XXXXXX HTTP/1.1 2024-06-25T10:07:32.519Z [DEBUG] provider.terraform-provider-cloudflare_v4.11.0: Host: api.cloudflare.com 2024-06-25T10:07:32.519Z [DEBUG] provider.terraform-provider-cloudflare_v4.11.0: User-Agent: terraform/1.7.5 terraform-plugin-sdk/2.10.1 terraform-provider-cloudflare/4.11.0 2024-06-25T10:07:32.519Z [DEBUG] provider.terraform-provider-cloudflare_v4.11.0: Authorization: [redacted]

Pravallika1995 commented 1 week ago

TF_LOG_DEBUG.txt