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

Failed to import bucket resource #2630

Closed
shawnzhu opened this issue May 14, 2021 · 2 comments
Closed

Failed to import bucket resource #2630

shawnzhu opened this issue May 14, 2021 · 2 comments
Labels
service/Object Storage Issues related to Cloud Object Storage

Comments

@shawnzhu
Copy link

shawnzhu commented May 14, 2021

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 other comments that do not add relevant new information or questions, 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 CLI and Terraform IBM Provider Version

> terraform -v
Terraform v0.15.3
on linux_amd64
+ provider registry.terraform.io/ibm-cloud/ibm v1.13.0

Affected Resource(s)

  • ibm_cos_bucket

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

provider "ibm" {
  generation = 2
  region     = var.region
}

resource "ibm_resource_instance" "cos_instance" {
  name     = "<actual-resource-name>"
  service  = "cloud-object-storage"
  location = var.region
  plan     = "standard"
}

resource "ibm_cos_bucket" "bucket_1" {
  bucket_name          = "bucket_1"
  resource_instance_id = ibm_resource_instance.cos_instance.id
}

Debug Output

Panic Output

Expected Behavior

It should import a bucket resource into state.

Actual Behavior

got Error: Plugin did not respond

> terraform import ibm_cos_bucket.bucket_1 <actual-bucket-crn>
ibm_cos_bucket.bucket_1: Importing from ID "<actual-bucket-crn>"...
ibm_cos_bucket.bucket_1: Import prepared!
  Prepared ibm_cos_bucket for import
ibm_cos_bucket.bucket_1: Refreshing state... [id=<actual-bucket-crn>]
╷
│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more details.
╵


Stack trace from the terraform-provider-ibm_v1.13.0 plugin:

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

goroutine 29 [running]:
github.com/IBM-Cloud/terraform-provider-ibm/ibm.parseBucketId(0xc000dee120, 0x8f, 0x238a5b3, 0xa, 0xc000308a00, 0xf)
        /Users/hkantare/go/src/github.com/IBM-Cloud/terraform-provider-ibm/ibm/resource_ibm_cos_bucket.go:630 +0x40c
github.com/IBM-Cloud/terraform-provider-ibm/ibm.resourceIBMCOSExists(0xc000104690, 0x2368e40, 0xc000308a00, 0xc000104690, 0x0, 0x0)
        /Users/hkantare/go/src/github.com/IBM-Cloud/terraform-provider-ibm/ibm/resource_ibm_cos_bucket.go:527 +0xf1
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0007ee200, 0xc000da4370, 0x2368e40, 0xc000308a00, 0xc000500230, 0x0, 0x0)
        /Users/hkantare/go/pkg/mod/github.com/hashicorp/[email protected]/helper/schema/resource.go:440 +0x24d
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ReadResource(0xc0005b31e8, 0x296b920, 0xc000da21b0, 0xc000da40a0, 0xc0005b31e8, 0x0, 0xc000c9fb30)
        /Users/hkantare/go/pkg/mod/github.com/hashicorp/[email protected]/internal/helper/plugin/grpc_provider.go:525 +0x3d8
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler(0x22d5e60, 0xc0005b31e8, 0x296b920, 0xc000da21b0, 0xc000094960, 0x0, 0x296b920, 0xc000da21b0, 0xc000dde480, 0x231)
        /Users/hkantare/go/pkg/mod/github.com/hashicorp/[email protected]/internal/tfplugin5/tfplugin5.pb.go:3153 +0x217
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00021f980, 0x29852a0, 0xc000d42300, 0xc0003be300, 0xc000b0c150, 0x3957050, 0x0, 0x0, 0x0)
        /Users/hkantare/go/pkg/mod/google.golang.org/[email protected]/server.go:1024 +0x4f4
google.golang.org/grpc.(*Server).handleStream(0xc00021f980, 0x29852a0, 0xc000d42300, 0xc0003be300, 0x0)
        /Users/hkantare/go/pkg/mod/google.golang.org/[email protected]/server.go:1313 +0xd97
google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0002e6320, 0xc00021f980, 0x29852a0, 0xc000d42300, 0xc0003be300)
        /Users/hkantare/go/pkg/mod/google.golang.org/[email protected]/server.go:722 +0xbb
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /Users/hkantare/go/pkg/mod/google.golang.org/[email protected]/server.go:720 +0xa1

Error: The terraform-provider-ibm_v1.13.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.

Steps to Reproduce

  1. terraform import ibm_resource_instance.cos_instance <cos_crn> - works
  2. terraform import ibm_cos_bucket.bucket_1 <bucket_CRN> - doesn't work

Important Factoids

References

@kavya498
Copy link
Collaborator

@shawnzhu
Can you make sure the bucket id that is using during import is a combination of $CRN:meta:$buckettype:$bucketlocation
please refer:
https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/cos_bucket#import

@kavya498 kavya498 added the service/Object Storage Issues related to Cloud Object Storage label May 17, 2021
@shawnzhu
Copy link
Author

the bucket id $CRN:meta:$buckettype:$bucketlocation works for me! Thank you for the hint!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service/Object Storage Issues related to Cloud Object Storage
Projects
None yet
Development

No branches or pull requests

2 participants