Terraform
List with a Non-Framework Resource
If the corresponding resource implementation is not a framework resource then the list resource must define the metadata as well as either the list.ListResourceWithRawV5Schemas interface or list.ListResourceWithRawV6Schemas interface interface.
These interfaces expose either a RawV5Schemas or RawV6Schemas method that allows the practitioner to supply the resource as well as identity schema information upfront.
RawV5Schemas and RawV6Schemas Method
A list resource that extends a non-framework resource must supply the relevant schema information upfront as well as define the Metadata method. This is done by implementing either of the methods below, depending on the protocol version the resource is based on.
list.ListResourceWithRawV5SchemasinterfaceRawV5Schemasmethodlist.ListResourceWithRawV6SchemasinterfaceRawV6Schemasmethod
In this example, the resource examplecloud_thing is not defined with framework but is based on protocol v5:
type ThingListResource struct {}
func (r *ThingListResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = "examplecloud_thing"
}
func (r *ThingListResource) RawV5Schemas(ctx context.Context, req list.RawV5SchemaRequest, resp *list.RawV5SchemaResponse) {
// This sets the resource schema information for the associated resource
resp.ProtoV5Schema = &tfprotov5.Schema{
/* ... */
}
// This sets the resource identity schema information for the associated resource
resp.ProtoV5IdentitySchema = &tfprotov5.ResourceIdentitySchema{
/* ... */
}
}