From b38c848a90e9a7b8aa5bb0432c33872e5a010dce Mon Sep 17 00:00:00 2001 From: Sean Conroy Date: Mon, 14 Oct 2024 15:49:39 +0100 Subject: [PATCH] Resolve issue #348 --- docs/resources/attach_feature_device_template.md | 8 ++++++++ .../sdwan_attach_feature_device_template/import.sh | 1 + .../resource_sdwan_attach_feature_device_template.go | 6 ++++++ 3 files changed, 15 insertions(+) create mode 100644 examples/resources/sdwan_attach_feature_device_template/import.sh diff --git a/docs/resources/attach_feature_device_template.md b/docs/resources/attach_feature_device_template.md index e1139dddc..c6533557a 100644 --- a/docs/resources/attach_feature_device_template.md +++ b/docs/resources/attach_feature_device_template.md @@ -48,3 +48,11 @@ Required: - `id` (String) Device ID - `variables` (Map of String) Device variables + +## Import + +Import is supported using the following syntax: + +```shell +terraform import sdwan_attach_feature_device_template.example "f6b2c44c-693c-4763-b010-895aa3d236bd" +``` diff --git a/examples/resources/sdwan_attach_feature_device_template/import.sh b/examples/resources/sdwan_attach_feature_device_template/import.sh new file mode 100644 index 000000000..5108a9808 --- /dev/null +++ b/examples/resources/sdwan_attach_feature_device_template/import.sh @@ -0,0 +1 @@ +terraform import sdwan_attach_feature_device_template.example "f6b2c44c-693c-4763-b010-895aa3d236bd" diff --git a/internal/provider/resource_sdwan_attach_feature_device_template.go b/internal/provider/resource_sdwan_attach_feature_device_template.go index 373e91125..31fde518f 100644 --- a/internal/provider/resource_sdwan_attach_feature_device_template.go +++ b/internal/provider/resource_sdwan_attach_feature_device_template.go @@ -23,6 +23,7 @@ import ( "strings" "github.com/CiscoDevNet/terraform-provider-sdwan/internal/provider/helpers" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" @@ -34,6 +35,7 @@ import ( // Ensure provider defined types fully satisfy framework interfaces var _ resource.Resource = &AttachFeatureDeviceTemplateResource{} +var _ resource.ResourceWithImportState = &AttachFeatureDeviceTemplateResource{} func NewAttachFeatureDeviceTemplateResource() resource.Resource { return &AttachFeatureDeviceTemplateResource{} @@ -239,3 +241,7 @@ func (r *AttachFeatureDeviceTemplateResource) Delete(ctx context.Context, req re resp.State.RemoveResource(ctx) } + +func (r *AttachFeatureDeviceTemplateResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +}