Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform import fails for azurerm_iothub_dps #5945

Closed
mark-greene opened this issue Feb 29, 2020 · 3 comments · Fixed by #6570
Closed

Terraform import fails for azurerm_iothub_dps #5945

mark-greene opened this issue Feb 29, 2020 · 3 comments · Fixed by #6570
Milestone

Comments

@mark-greene
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

Terraform v0.12.21

Initializing provider plugins...

  • Checking for available provider plugins...
  • Downloading plugin for provider "azuread" (hashicorp/azuread) 0.7.0...
  • Downloading plugin for provider "null" (hashicorp/null) 2.1.2...
  • Downloading plugin for provider "external" (hashicorp/external) 1.2.0...
  • Downloading plugin for provider "azurerm" (hashicorp/azurerm) 1.44.0...

Affected Resource(s)

  • azurerm_iothub_dps

Terraform Configuration Files

resource "azurerm_iothub_dps" "iot_dps" {
  name                = local.dps_name
  resource_group_name = local.dps_resource_group
  location            = local.dps_location

  sku {
    name     = "S1"
    capacity = "1"
  }

  linked_hub {
    connection_string = data.external.connection_string.result["connection"]
    location          = azurerm_iothub.iot.location
  }

  count = var.location == "eastus2" ? 1 : 0
}

Debug Output

Panic Output

terraform import -var stack=iot -var location=eastus2 -var-file=variables/prod.tfvars azurerm_iothub_dps.iot_dps[0] /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Cloud.Prod.cloud-iot/providers/Microsoft.Devices/ProvisioningServices/prod-cloud-iot-dps
azurerm_iothub_dps.iot_dps[0]: Importing from ID "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Cloud.Prod.cloud-iot/providers/Microsoft.Devices/ProvisioningServices/prod-cloud-iot-dps"...

azurerm_iothub_dps.iot_dps[0]: Import prepared!
Prepared azurerm_iothub_dps for import
azurerm_iothub_dps.iot_dps[0]: Refreshing state... [id=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Cloud.Prod.cloud-iot/providers/Microsoft.Devices/ProvisioningServices/prod-cloud-iot-dps]

Error: rpc error: code = Unavailable desc = transport is closing

panic: runtime error: invalid memory address or nil pointer dereference
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x3212d76]
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4:
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: goroutine 79 [running]:
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/iothub.flattenIoTHubDPSSku(...)
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/iothub/resource_arm_iothub_dps.go:361
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/iothub.resourceArmIotHubDPSRead(0xc0005f0620, 0x39652e0, 0xc0000c86c0, 0x0, 0x0)
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/iothub/resource_arm_iothub_dps.go:250 +0x586
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000503900, 0xc0008d8280, 0x39652e0, 0xc0000c86c0, 0xc000148b10, 0x0, 0x0)
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/resource.go:455 +0x119
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ReadResource(0xc00000eb08, 0x46b9440, 0xc000942360, 0xc0008d80a0, 0xc00000eb08, 0xc000942360, 0xc000991bd0)
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin/grpc_provider.go:525 +0x3d7
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler(0x3ccf080, 0xc00000eb08, 0x46b9440, 0xc000942360, 0xc000d9a060, 0x0, 0x46b9440, 0xc000942360, 0xc000750480, 0x178)
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5/tfplugin5.pb.go:3153 +0x23e
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: google.golang.org/grpc.(*Server).processUnaryRPC(0xc0003c4580, 0x4710940, 0xc000092780, 0xc000d46100, 0xc000869e00, 0x7aa6730, 0x0, 0x0, 0x0)
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:995 +0x466
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: google.golang.org/grpc.(*Server).handleStream(0xc0003c4580, 0x4710940, 0xc000092780, 0xc000d46100, 0x0)
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1275 +0xda6
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc000286250, 0xc0003c4580, 0x4710940, 0xc000092780, 0xc000d46100)
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:710 +0x9f
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: created by google.golang.org/grpc.(*Server).serveStreams.func1
2020-02-29T10:43:33.883-0500 [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:708 +0xa1
2020-02-29T10:43:33.892-0500 [DEBUG] plugin: plugin process exited: path=/home/mark/projects/devops/devops-cloud/iot/.terraform/plugins/linux_amd64/terraform-provider-azurerm_v1.44.0_x4 pid=26889 error="exit status 2"
2020/02/29 10:43:33 [ERROR] : eval: *terraform.EvalRefresh, err: rpc error: code = Unavailable desc = transport is closing
2020/02/29 10:43:33 [ERROR] : eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2020/02/29 10:43:33 [TRACE] [walkImport] Exiting eval tree: import azurerm_iothub_dps.iot_dps[0] result
2020/02/29 10:43:33 [TRACE] vertex "import azurerm_iothub_dps.iot_dps[0] result": visit complete
2020/02/29 10:43:33 [TRACE] vertex "azurerm_iothub_dps.iot_dps[0] (import id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Cloud.Prod.cloud-iot/providers/Microsoft.Devices/ProvisioningServices/prod-cloud-iot-dps")": dynamic subgraph encountered errors
2020/02/29 10:43:33 [TRACE] vertex "azurerm_iothub_dps.iot_dps[0] (import id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Cloud.Prod.cloud-iot/providers/Microsoft.Devices/ProvisioningServices/prod-cloud-iot-dps")": visit complete
2020/02/29 10:43:33 [TRACE] dag/walk: upstream of "provider.azurerm (close)" errored, so skipping
2020/02/29 10:43:33 [TRACE] dag/walk: upstream of "root" errored, so skipping
2020-02-29T10:43:34.123-0500 [DEBUG] plugin: plugin exited

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform1 so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

SECURITY WARNING: the "crash.log" file that was created may contain
sensitive information that must be redacted before it is safe to share
on the issue tracker.

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Expected Behavior

Actual Behavior

Steps to Reproduce

  1. terraform import -var stack=iot -var location=eastus2 -var-file=variables/prod.tfvars azurerm_iothub_dps.iot_dps[0] /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Cloud.Prod.cloud-iot/providers/Microsoft.Devices/ProvisioningServices/prod-cloud-iot-dps azurerm_iothub_dps.iot_dps[0]: Importing from ID "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Cloud.Prod.cloud-iot/providers/Microsoft.Devices/ProvisioningServices/prod-cloud-iot-dps"

Important Factoids

References

  • #0000
@ghost ghost added bug crash labels Feb 29, 2020
@mark-greene
Copy link
Author

mark-greene commented Mar 5, 2020

This seems to be related to the Data Provisioning Service Resource ID. When I provisioned DPS via the azure cli several months ago before the azure provider offered support, the Resource ID has the form "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Prod.iot/providers/Microsoft.Devices/ProvisioningServices/prod-iot-dps". Services created now have the form, /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Prod.iot/providers/Microsoft.Devices/provisioningServices/prod-iot-dps". When I manually import (edit) the state and use "ProvisioningServices" a terraform plan crashes. When I use "provisioningServices" the plan succeeds but believes it must replace the resource.

And I upgraded to 2.0 and it behaves exactly the same.

@ghost
Copy link

ghost commented Apr 23, 2020

This has been released in version 2.7.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.7.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented May 23, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators May 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants