Open stanxing opened 2 years ago
still cannot import sgr provider: required_providers { alicloud = { source = "aliyun/alicloud" version = "~> 1.129" } }
command: terraform import alicloud_security_group_rule.rule1 sgr-wz94ntdd0kr6ns3m6hgy
error stack: │ 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-alicloud_v1.224.0 plugin:
panic: runtime error: index out of range [1] with length 1
goroutine 88 [running]: github.com/aliyun/terraform-provider-alicloud/alicloud.resourceAliyunSecurityGroupRuleRead(0x14003156770, {0x10b8dcda0?, 0x140006cc000?}) github.com/aliyun/terraform-provider-alicloud/alicloud/resource_alicloud_security_group_rule.go:300 +0x878 github.com/hashicorp/terraform-plugin-sdk/helper/schema.(Resource).RefreshWithoutUpgrade(0x1400110dc20, 0x14003140aa0, {0x10b8dcda0, 0x140006cc000}) github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/resource.go:470 +0x1a8 github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(GRPCProviderServer).ReadResource(0x14000144e40, {0x140014dc5a0?, 0x14003152680?}, 0x140014dc5a0) github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:535 +0x338 github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler({0x10b0de3c0?, 0x14000144e40}, {0x10b953910, 0x1400316b350}, 0x14003152680, 0x0) github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3269 +0x170 google.golang.org/grpc.(Server).processUnaryRPC(0x140006f6800, {0x10b953910, 0x1400316b2c0}, {0x10b9a9340, 0x14000d1a680}, 0x14002cff9e0, 0x14000e78c90, 0x11276d630, 0x0) google.golang.org/grpc@v1.62.1/server.go:1386 +0xc84 google.golang.org/grpc.(Server).handleStream(0x140006f6800, {0x10b9a9340, 0x14000d1a680}, 0x14002cff9e0) google.golang.org/grpc@v1.62.1/server.go:1797 +0xcc0 google.golang.org/grpc.(Server).serveStreams.func2.1() google.golang.org/grpc@v1.62.1/server.go:1027 +0x8c created by google.golang.org/grpc.(Server).serveStreams.func2 google.golang.org/grpc@v1.62.1/server.go:1038 +0x160
Error: The terraform-provider-alicloud_v1.224.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.
I had the same problem but then found out that a security group rule ID has the format
<security_group_id>:<type>:<ip_protocol>:<port_range>:<nic_type>:<cidr_ip>:<policy>:<priority>
according to this https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/security_group_rule#attributes-reference
So to import a security group rule into a terraform state the import command would be like the following one
terraform import 'alicloud_security_group_rule.this["10.0.0.0/8"]' 'sg-1whsjcurngkeirir2qwe:ingress:all:-1/-1:internet:10.0.0.0/8:accept:1'
Terraform Version
Terraform v1.1.7 on darwin_arm64
Affected Resource(s)
Please list the resources as a list, for example:
Terraform Command
Panic Logs
I can not find import docs, so I referenced the docs of aws. https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule#import