hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.87k stars 9.21k forks source link

[Bug]: Cannot import QuickSight dataset #31584

Open ququcana opened 1 year ago

ququcana commented 1 year ago

Terraform Core Version

1.4.6

AWS Provider Version

4.67.0

Affected Resource(s)

aws_quicksight_data_set

Expected Behavior

Should be able to import a QuickSight DataSet.

Actual Behavior

│ Error: Request cancelled
│ 
│ The plugin.(*GRPCProvider).ReadResource request was cancelled.

and terraform-provider-aws_v4.67.0_x5 plugin crashed

Relevant Error/Panic Output Snippet

terraform import aws_quicksight_data_set.planner_projects_employees_with_nearest_end 015469768957,prd_planner_projects_employees_with_nearest_end
aws_quicksight_data_set.planner_projects_employees_with_nearest_end: Importing from ID "015469768957,prd_planner_projects_employees_with_nearest_end"...
data.aws_caller_identity.current: Reading...
data.aws_region.current: Reading...
aws_quicksight_data_set.planner_projects_employees_with_nearest_end: Import prepared!
  Prepared aws_quicksight_data_set for import
aws_quicksight_data_set.planner_projects_employees_with_nearest_end: Refreshing state... [id=015469768957,prd_planner_projects_employees_with_nearest_end]
data.aws_region.current: Read complete after 0s [id=us-west-2]
data.aws_caller_identity.current: Read complete after 0s [id=015469768957]
╷
│ Error: Request cancelled
│ 
│ The plugin.(*GRPCProvider).ReadResource request was cancelled.
╵

Releasing state lock. This may take a few moments...

Stack trace from the terraform-provider-aws_v4.67.0_x5 plugin:

panic: interface conversion: interface {} is map[string]interface {}, not []interface {}

goroutine 28 [running]:
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.SerializeValueForHash(0xca76e80?, {0xca76e80, 0xc005928c90?}, 0xc0074088c0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/serialize.go:31 +0x733
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.SerializeResourceForHash(0x4?, {0xca76e80?, 0xc005928c30}, 0x8?)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/serialize.go:115 +0x2c8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.serializeCollectionMemberForHash(0x10c69e5?, {0xca76e80, 0xc005928c30}, {0xe593dc0?, 0xc00063fce0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/serialize.go:125 +0xab
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.SerializeValueForHash(0xca76e80?, {0xbc477e0, 0xc006717248?}, 0xc007408c80)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/serialize.go:33 +0x712
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.SerializeResourceForHash(0x203001?, {0xca76e80?, 0xc005928c00}, 0x10fb875?)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/serialize.go:115 +0x2c8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.serializeCollectionMemberForHash(0xc0073d2b48?, {0xca76e80, 0xc005928c00}, {0xe593dc0?, 0xc00063fdc0})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/serialize.go:125 +0xab
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.SerializeValueForHash(0xca76e80?, {0xbc477e0, 0xc006717260?}, 0xc007408f00)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/serialize.go:33 +0x712
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.SerializeResourceForHash(0xc0073d2b18?, {0xca76e80?, 0xc005928720}, 0x1070aa6?)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/serialize.go:115 +0x2c8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.HashResource.func1({0xca76e80?, 0xc005928720?})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/set.go:33 +0x4b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Set).hash(0x20?, {0xca76e80?, 0xc005928720?})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/set.go:218 +0x2c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Set).add(0xc006701720, {0xca76e80?, 0xc005928720}, 0x0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/set.go:198 +0x96
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Set).Add(...)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/set.go:76
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.NewSet(0xc0073fed10, {0xc006754a40, 0x3, 0x6?})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/set.go:63 +0xa5
github.com/hashicorp/terraform-provider-aws/internal/service/quicksight.flattenLogicalTableMap(0xc0087be580?, 0xe7f7876?)
        github.com/hashicorp/terraform-provider-aws/internal/service/quicksight/data_set.go:2154 +0x36f
github.com/hashicorp/terraform-provider-aws/internal/service/quicksight.resourceDataSetRead({0xfca11c0, 0xc00418f9e0}, 0xc0087be580, {0xe78cb00?, 0xc0003c4800?})
        github.com/hashicorp/terraform-provider-aws/internal/service/quicksight/data_set.go:960 +0xbef
github.com/hashicorp/terraform-provider-aws/internal/provider.interceptedHandler[...].func1(0x0?, {0xe78cb00?, 0xc0003c4800?})
        github.com/hashicorp/terraform-provider-aws/internal/provider/intercept.go:95 +0x175
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xfca11c0?, {0xfca11c0?, 0xc004181c50?}, 0xd?, {0xe78cb00?, 0xc0003c4800?})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/resource.go:719 +0x87
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0018f09a0, {0xfca11c0, 0xc004181c50}, 0xc0087d6d00, {0xe78cb00, 0xc0003c4800})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/resource.go:1015 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc0028216b0, {0xfca11c0?, 0xc004181b30?}, 0xc002137280)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/grpc_provider.go:613 +0x4a5
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.muxServer.ReadResource({0xc004124c60, 0xc004124cc0, {0xc0033d6780, 0x2, 0x2}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...)
        github.com/hashicorp/terraform-plugin-mux@v0.10.0/tf5muxserver/mux_server_ReadResource.go:26 +0x102
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0023223c0, {0xfca11c0?, 0xc004180360?}, 0xc0087aa060)
        github.com/hashicorp/terraform-plugin-go@v0.15.0/tfprotov5/tf5server/server.go:748 +0x4b1
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0xe4780c0?, 0xc0023223c0}, {0xfca11c0, 0xc004180360}, 0xc002dfa000, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.15.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:383 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0061cc3c0, {0xfcb1a60, 0xc0040f3520}, 0xc0087ac000, 0xc004125f20, 0x168fe670, 0x0)
        google.golang.org/grpc@v1.54.0/server.go:1345 +0xdf0
google.golang.org/grpc.(*Server).handleStream(0xc0061cc3c0, {0xfcb1a60, 0xc0040f3520}, 0xc0087ac000, 0x0)
        google.golang.org/grpc@v1.54.0/server.go:1722 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.54.0/server.go:966 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.54.0/server.go:964 +0x28a

Error: The terraform-provider-aws_v4.67.0_x5 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.

Terraform Configuration Files

locals {
  prefix = "prd"
}

resource "aws_quicksight_data_set" "planner_projects_employees_with_nearest_end" {
  data_set_id = "${local.prefix}_planner_projects_employees_with_nearest_end"
  name         = "[${upper(local.prefix)}]  planner_projects_employees_with_nearest_end"
  import_mode = "DIRECT_QUERY"

  physical_table_map {
    physical_table_map_id = "abc"
  }
}

Steps to Reproduce

terraform import aws_quicksight_data_set.planner_projects_employees_with_nearest_end 015469768957,prd_planner_projects_employees_with_nearest_end

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

XnS commented 1 year ago

Also happens with latest 5.13.1 in combination with terraform 1.5.4

jar-b commented 3 months ago

This crash is originating in the upstream Terraform Plugin SDK V2, but may be caused by an inaccurate schema mapping somewhere in the aws_quicksight_data_set resource. Specifically, this is occurring while trying to create a hash of the logical_table_map:

https://github.com/hashicorp/terraform-provider-aws/blob/a89fe9b3017efc499d4b9d01c7c662266d884888/internal/service/quicksight/data_set.go#L2161

Is it possible to share the structure of the logical table maps on the resource that is being imported? This might help to diagnose where the schema definition is incorrect.