Skip to content

Data source schema incorrectly allows identity to be defined #1511

@remyleone

Description

@remyleone

SDK version

github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0

Relevant provider source code

func blockIdentity() *schema.ResourceIdentity {
	return &schema.ResourceIdentity{
		Version: 0,
		SchemaFunc: func() map[string]*schema.Schema {
			return map[string]*schema.Schema{
				"snapshot_id": {
					Type:              schema.TypeString,
					RequiredForImport: true,
					Description:       "Snapshot ID",
				},
				"zone": {
					Type:              schema.TypeString,
					RequiredForImport: true,
					Description:       "Zone ID",
				},
			}
		},
	}
}

Terraform Configuration Files

resource "scaleway_instance_volume" "test" {
						size_in_gb = 2
						type = "b_ssd"
					}

					resource "scaleway_instance_snapshot" "from_volume" {
						name = "%s"
						volume_id = scaleway_instance_volume.test.id
					}

					data "scaleway_instance_snapshot" "by_id" {
						snapshot_id = scaleway_instance_snapshot.from_volume.id
					}

					data "scaleway_instance_snapshot" "by_name" {
						name = scaleway_instance_snapshot.from_volume.name
					}

https://github.com/scaleway/terraform-provider-scaleway/blob/0caa7e64c42a774a75c339367d27c2b9b0d16de4/internal/services/instance/snapshot_data_source_test.go#L12

Debug Output

Error: -25T13:57:43.526Z [ERROR] sdk.proto: Response contains error diagnostic: diagnostic_detail="" diagnostic_severity=ERROR diagnostic_summary="Resource does not have Identity schema. Please set one in order to use Identity(). This is always a problem in the provider code." tf_req_id=f9a15696-5d31-a10a-dbf8-a1d0039615c3 tf_provider_addr=registry.terraform.io/hashicorp/scaleway tf_proto_version=5.9 tf_rpc=ReadDataSource tf_data_source_type=scaleway_block_snapshot

Expected Behavior

The identity should be taken into account

Actual Behavior

  | Error: Resource does not have Identity schema. Please set one in order to use Identity(). This is always a problem in the provider code.

Steps to Reproduce

scaleway/terraform-provider-scaleway#3276

References

https://github.com/search?q=repo%3Ahashicorp%2Fterraform-plugin-sdk+%22Resource+does+not+have+Identity+schema.%22&type=code

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions