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

fix: incorrect indexing of resource data id attributes #1753

Conversation

terakoya76
Copy link
Contributor

@terakoya76 terakoya76 commented Jul 5, 2022

Summary

Fixed incorrect indexing introduced by #1668

Behavior

environment

$ tf version
Terraform v1.2.4
on linux_amd64
+ provider registry.terraform.io/cloudflare/cloudflare v3.18.0

before

$  terraform import cloudflare_tunnel_route.example $CLOUDFLARE_ACCOUNT_ID/192.168.0.0/16/$CLOUDFLARE_VNET_ID
cloudflare_tunnel_route.example: Importing from ID "xxxx/192.168.0.0/16/yyyy"...
╷
│ Error: Plugin did not respond
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ImportResourceState call. The plugin logs may contain more details.
╵


Stack trace from the terraform-provider-cloudflare_v3.18.0 plugin:

panic: runtime error: index out of range [4] with length 4

goroutine 66 [running]:
github.com/cloudflare/terraform-provider-cloudflare/internal/provider.resourceCloudflareTunnelRouteImport({0xf7a5f0?, 0xc000628900?}, 0xc000396300, {0xd?, 0xe217eb?})
        github.com/cloudflare/terraform-provider-cloudflare/internal/provider/resource_cloudflare_tunnel_route.go:155 +0x268
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Provider).ImportState(0xc0003869c0, {0xf7a5f0, 0xc000628900}, 0xc0000936d0, {0xc000114420, 0x54})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.17.0/helper/schema/provider.go:385 +0x1ac
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ImportResourceState(0xc000395230, {0xf7a548?, 0xc0004bc580?}, 0xc00038cb80)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.17.0/helper/schema/grpc_provider.go:1088 +0xf4
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ImportResourceState(0xc0003fedc0, {0xf7a5f0?, 0xc0006281e0?}, 0xc00062a0a0)
        github.com/hashicorp/terraform-plugin-go@v0.9.1/tfprotov5/tf5server/server.go:841 +0x20e
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ImportResourceState_Handler({0xde30a0?, 0xc0003fedc0}, {0xf7a5f0, 0xc0006281e0}, 0xc00058c300, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.9.1/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:403 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0003ac8c0, {0xf7d180, 0xc0002901a0}, 0xc0002b4240, 0xc0004f96b0, 0x14959b8, 0x0)
        google.golang.org/grpc@v1.46.0/server.go:1283 +0xcfd
google.golang.org/grpc.(*Server).handleStream(0xc0003ac8c0, {0xf7d180, 0xc0002901a0}, 0xc0002b4240, 0x0)
        google.golang.org/grpc@v1.46.0/server.go:1620 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.46.0/server.go:922 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.46.0/server.go:920 +0x28a

Error: The terraform-provider-cloudflare_v3.18.0 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

---------------------------------------------

after

$  terraform import cloudflare_tunnel_route.example $CLOUDFLARE_ACCOUNT_ID/192.168.0.0/16/$CLOUDFLARE_VNET_ID
cloudflare_tunnel_route.example: Importing from ID "xxxx/192.168.0.0/16/yyyy"...
cloudflare_tunnel_route.example: Import prepared!
  Prepared cloudflare_tunnel_route for import
cloudflare_tunnel_route.example: Refreshing state... [id=676764a535c4f566c18f215d8abf05ca]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 2022

changelog detected ✅

@jacobbednarz jacobbednarz merged commit d0b4da9 into cloudflare:master Jul 5, 2022
@github-actions github-actions bot added this to the v3.19.0 milestone Jul 5, 2022
github-actions bot pushed a commit that referenced this pull request Jul 5, 2022
@terakoya76 terakoya76 deleted the fix_incorrect_indexing_in_vnet_import branch July 6, 2022 02:01
@github-actions
Copy link
Contributor

This functionality has been released in v3.19.0 of the Terraform Cloudflare Provider.

Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants