From 9298f458b61ac9349e5b14553763063b916770ad Mon Sep 17 00:00:00 2001 From: Erik Merkle Date: Mon, 11 Jul 2022 14:25:41 -0500 Subject: [PATCH] Fix private_link_endpoint import (TERRA-73) --- docs/resources/private_link_endpoint.md | 9 ++++++++- examples/resources/astra_private_link_endpoint/import.sh | 9 ++++++++- internal/provider/resource_private_link_endpoint.go | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/docs/resources/private_link_endpoint.md b/docs/resources/private_link_endpoint.md index 5811a63..2502d17 100644 --- a/docs/resources/private_link_endpoint.md +++ b/docs/resources/private_link_endpoint.md @@ -160,5 +160,12 @@ resource "astra_private_link_endpoint" "az_private_link_endpoint" { Import is supported using the following syntax: ```shell -terraform import astra_private_link_endpoint.example a6bc9c26-e7ce-424f-84c7-0a00afb12588 +# Amazon AWS example +terraform import astra_private_link_endpoint.example a6bc9c26-e7ce-424f-84c7-0a00afb12588/datacenter/a6bc9c26-e7ce-424f-84c7-0a00afb12588-1/endpoint/vpce-0f7aed6e7a18a1791 + +# Google GCP example +terraform import astra_private_link_endpoint.example a6bc9c26-e7ce-424f-84c7-0a00afb12588/datacenter/a6bc9c26-e7ce-424f-84c7-0a00afb12588-1/endpoint/13585698993864708 + +# Azure EKS example +terraform import astra_private_link_endpoint.example a6bc9c26-e7ce-424f-84c7-0a00afb12588/datacenter/a6bc9c26-e7ce-424f-84c7-0a00afb12588-1/endpoint/dc5ee5b1-4fc2-463e-a56b-ff54dd38b879/providers/Microsoft.Network/privateEndpoints/private-endpoint-example ``` diff --git a/examples/resources/astra_private_link_endpoint/import.sh b/examples/resources/astra_private_link_endpoint/import.sh index 907040d..ef20ba8 100644 --- a/examples/resources/astra_private_link_endpoint/import.sh +++ b/examples/resources/astra_private_link_endpoint/import.sh @@ -1 +1,8 @@ -terraform import astra_private_link_endpoint.example a6bc9c26-e7ce-424f-84c7-0a00afb12588 \ No newline at end of file +# Amazon AWS example +terraform import astra_private_link_endpoint.example a6bc9c26-e7ce-424f-84c7-0a00afb12588/datacenter/a6bc9c26-e7ce-424f-84c7-0a00afb12588-1/endpoint/vpce-0f7aed6e7a18a1791 + +# Google GCP example +terraform import astra_private_link_endpoint.example a6bc9c26-e7ce-424f-84c7-0a00afb12588/datacenter/a6bc9c26-e7ce-424f-84c7-0a00afb12588-1/endpoint/13585698993864708 + +# Azure EKS example +terraform import astra_private_link_endpoint.example a6bc9c26-e7ce-424f-84c7-0a00afb12588/datacenter/a6bc9c26-e7ce-424f-84c7-0a00afb12588-1/endpoint/dc5ee5b1-4fc2-463e-a56b-ff54dd38b879/providers/Microsoft.Network/privateEndpoints/private-endpoint-example \ No newline at end of file diff --git a/internal/provider/resource_private_link_endpoint.go b/internal/provider/resource_private_link_endpoint.go index 8abf3bc..1f239e8 100644 --- a/internal/provider/resource_private_link_endpoint.go +++ b/internal/provider/resource_private_link_endpoint.go @@ -126,7 +126,7 @@ func resourcePrivateLinkEndpointRead(ctx context.Context, d *schema.ResourceData } var astraEndpointIDStr string - if astraEndpointID == nil { + if astraEndpointID == nil || astraEndpointID == "" { // set it to the endpointID astraEndpointIDStr = endpointID } else {