Skip to content

Commit 941fc12

Browse files
committed
Support imports on plugin framework index
1 parent b38ec22 commit 941fc12

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

internal/elasticsearch/index/index/resource.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ import (
55

66
"github.com/elastic/terraform-provider-elasticstack/internal/clients"
77
"github.com/hashicorp/terraform-plugin-framework/diag"
8+
"github.com/hashicorp/terraform-plugin-framework/path"
89
"github.com/hashicorp/terraform-plugin-framework/resource"
910
)
1011

12+
// Ensure provider defined types fully satisfy framework interfaces
13+
var _ resource.Resource = &Resource{}
14+
var _ resource.ResourceWithConfigure = &Resource{}
15+
var _ resource.ResourceWithImportState = &Resource{}
16+
1117
type Resource struct {
1218
client *clients.ApiClient
1319
}
@@ -33,3 +39,8 @@ func (r *Resource) Configure(ctx context.Context, request resource.ConfigureRequ
3339
func (r *Resource) Metadata(ctx context.Context, request resource.MetadataRequest, response *resource.MetadataResponse) {
3440
response.TypeName = request.ProviderTypeName + "_elasticsearch_index"
3541
}
42+
43+
func (r *Resource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
44+
// Retrieve import ID and save to id attribute
45+
resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
46+
}

0 commit comments

Comments
 (0)