Skip to content

Commit 699de6d

Browse files
storage_mover_smb_file_share_endpoint: ResourceWithIdentity, guide error msg, Target Endpoint docs, inline tests
Made-with: Cursor
1 parent 4d906da commit 699de6d

File tree

4 files changed

+40
-26
lines changed

4 files changed

+40
-26
lines changed

internal/services/storagemover/storage_mover_smb_file_share_endpoint_resource.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/hashicorp/go-azure-helpers/lang/pointer"
1313
"github.com/hashicorp/go-azure-helpers/lang/response"
1414
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
15+
"github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids"
1516
"github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2025-07-01/endpoints"
1617
"github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2025-07-01/storagemovers"
1718
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
@@ -30,7 +31,10 @@ type StorageMoverSmbFileShareEndpointModel struct {
3031

3132
type StorageMoverSmbFileShareEndpointResource struct{}
3233

33-
var _ sdk.ResourceWithUpdate = StorageMoverSmbFileShareEndpointResource{}
34+
var (
35+
_ sdk.ResourceWithUpdate = StorageMoverSmbFileShareEndpointResource{}
36+
_ sdk.ResourceWithIdentity = StorageMoverSmbFileShareEndpointResource{}
37+
)
3438

3539
func (r StorageMoverSmbFileShareEndpointResource) ResourceType() string {
3640
return "azurerm_storage_mover_smb_file_share_endpoint"
@@ -44,6 +48,10 @@ func (r StorageMoverSmbFileShareEndpointResource) IDValidationFunc() pluginsdk.S
4448
return endpoints.ValidateEndpointID
4549
}
4650

51+
func (r StorageMoverSmbFileShareEndpointResource) Identity() resourceids.ResourceId {
52+
return &endpoints.EndpointId{}
53+
}
54+
4755
func (r StorageMoverSmbFileShareEndpointResource) Arguments() map[string]*pluginsdk.Schema {
4856
return map[string]*pluginsdk.Schema{
4957
"name": {
@@ -107,7 +115,7 @@ func (r StorageMoverSmbFileShareEndpointResource) Create() sdk.ResourceFunc {
107115
id := endpoints.NewEndpointID(storageMoverId.SubscriptionId, storageMoverId.ResourceGroupName, storageMoverId.StorageMoverName, model.Name)
108116
existing, err := client.Get(ctx, id)
109117
if err != nil && !response.WasNotFound(existing.HttpResponse) {
110-
return fmt.Errorf("checking for existing %s: %+v", id, err)
118+
return fmt.Errorf("checking for presence of existing %s: %+v", id, err)
111119
}
112120

113121
if !response.WasNotFound(existing.HttpResponse) {
@@ -133,7 +141,10 @@ func (r StorageMoverSmbFileShareEndpointResource) Create() sdk.ResourceFunc {
133141
}
134142

135143
metadata.SetID(id)
136-
return nil
144+
if err := pluginsdk.SetResourceIdentityData(metadata.ResourceData, &id); err != nil {
145+
return err
146+
}
147+
return metadata.Encode(&model)
137148
},
138149
}
139150
}
@@ -213,6 +224,9 @@ func (r StorageMoverSmbFileShareEndpointResource) Read() sdk.ResourceFunc {
213224
}
214225
}
215226

227+
if err := pluginsdk.SetResourceIdentityData(metadata.ResourceData, id); err != nil {
228+
return err
229+
}
216230
return metadata.Encode(&state)
217231
},
218232
}

internal/services/storagemover/storage_mover_smb_file_share_endpoint_resource_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ resource "azurerm_storage_mover" "test" {
129129
}
130130

131131
func (r StorageMoverSmbFileShareEndpointTestResource) basic(data acceptance.TestData) string {
132-
template := r.template(data)
133132
return fmt.Sprintf(`
134133
provider "azurerm" {
135134
features {}
@@ -143,11 +142,10 @@ resource "azurerm_storage_mover_smb_file_share_endpoint" "test" {
143142
storage_account_id = azurerm_storage_account.test.id
144143
file_share_name = azurerm_storage_share.test.name
145144
}
146-
`, template, data.RandomInteger)
145+
`, r.template(data), data.RandomInteger)
147146
}
148147

149148
func (r StorageMoverSmbFileShareEndpointTestResource) requiresImport(data acceptance.TestData) string {
150-
config := r.basic(data)
151149
return fmt.Sprintf(`
152150
%s
153151
@@ -157,11 +155,10 @@ resource "azurerm_storage_mover_smb_file_share_endpoint" "import" {
157155
storage_account_id = azurerm_storage_account.test.id
158156
file_share_name = azurerm_storage_share.test.name
159157
}
160-
`, config)
158+
`, r.basic(data))
161159
}
162160

163161
func (r StorageMoverSmbFileShareEndpointTestResource) complete(data acceptance.TestData) string {
164-
template := r.template(data)
165162
return fmt.Sprintf(`
166163
provider "azurerm" {
167164
features {}
@@ -176,11 +173,10 @@ resource "azurerm_storage_mover_smb_file_share_endpoint" "test" {
176173
file_share_name = azurerm_storage_share.test.name
177174
description = "Example SMB File Share Endpoint Description"
178175
}
179-
`, template, data.RandomInteger)
176+
`, r.template(data), data.RandomInteger)
180177
}
181178

182179
func (r StorageMoverSmbFileShareEndpointTestResource) update(data acceptance.TestData) string {
183-
template := r.template(data)
184180
return fmt.Sprintf(`
185181
provider "azurerm" {
186182
features {}
@@ -195,5 +191,5 @@ resource "azurerm_storage_mover_smb_file_share_endpoint" "test" {
195191
file_share_name = azurerm_storage_share.test.name
196192
description = "Updated SMB File Share Endpoint Description"
197193
}
198-
`, template, data.RandomInteger)
194+
`, r.template(data), data.RandomInteger)
199195
}

website/docs/r/storage_mover_smb_file_share_endpoint.html.markdown

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ subcategory: "Storage Mover"
33
layout: "azurerm"
44
page_title: "Azure Resource Manager: azurerm_storage_mover_smb_file_share_endpoint"
55
description: |-
6-
Manages a Storage Mover SMB File Share Endpoint.
6+
Manages a Storage Mover SMB File Share Target Endpoint.
77
---
88

99
# azurerm_storage_mover_smb_file_share_endpoint
1010

11-
Manages a Storage Mover SMB File Share Endpoint.
11+
Manages a Storage Mover **SMB File Share Target Endpoint** (an endpoint that targets an Azure Files SMB file share as the migration destination in the Azure portal).
12+
13+
-> **Note:** For a target endpoint that uses an Azure Storage **blob container**, use [`azurerm_storage_mover_target_endpoint`](storage_mover_target_endpoint.html) instead. For **NFS** file shares, use [`azurerm_storage_mover_nfs_file_share_target_endpoint`](storage_mover_nfs_file_share_target_endpoint.html).
1214

1315
## Example Usage
1416

@@ -43,42 +45,42 @@ resource "azurerm_storage_mover_smb_file_share_endpoint" "example" {
4345
storage_mover_id = azurerm_storage_mover.example.id
4446
storage_account_id = azurerm_storage_account.example.id
4547
file_share_name = azurerm_storage_share.example.name
46-
description = "Example SMB File Share Endpoint"
48+
description = "Example SMB File Share Target Endpoint"
4749
}
4850
```
4951

5052
## Arguments Reference
5153

5254
The following arguments are supported:
5355

54-
* `name` - (Required) Specifies the name which should be used for this Storage Mover SMB File Share Endpoint. Changing this forces a new resource to be created.
56+
* `name` - (Required) Specifies the name of this Storage Mover SMB File Share Target Endpoint. Changing this forces a new resource to be created.
5557

56-
* `storage_mover_id` - (Required) Specifies the ID of the Storage Mover for this SMB File Share Endpoint. Changing this forces a new resource to be created.
58+
* `storage_mover_id` - (Required) Specifies the ID of the Storage Mover. Changing this forces a new resource to be created.
5759

58-
* `storage_account_id` - (Required) Specifies the ID of the Storage Account for this SMB File Share Endpoint. Changing this forces a new resource to be created.
60+
* `storage_account_id` - (Required) Specifies the ID of the Storage Account that hosts the SMB file share. Changing this forces a new resource to be created.
5961

60-
* `file_share_name` - (Required) Specifies the name of the SMB File Share for this Storage Mover SMB File Share Endpoint. Changing this forces a new resource to be created.
62+
* `file_share_name` - (Required) The name of the Azure Files share (the same value as the `name` argument of the [`azurerm_storage_share`](storage_share.html) resource). Changing this forces a new resource to be created.
6163

62-
* `description` - (Optional) Specifies a description for the Storage Mover SMB File Share Endpoint.
64+
* `description` - (Optional) A description for this Target Endpoint.
6365

6466
## Attributes Reference
6567

6668
In addition to the Arguments listed above - the following Attributes are exported:
6769

68-
* `id` - The ID of the Storage Mover SMB File Share Endpoint.
70+
* `id` - The ID of the Storage Mover SMB File Share Target Endpoint.
6971

7072
## Timeouts
7173

7274
The `timeouts` block allows you to specify [timeouts](https://developer.hashicorp.com/terraform/language/resources/configure#define-operation-timeouts) for certain actions:
7375

74-
* `create` - (Defaults to 30 minutes) Used when creating the Storage Mover SMB File Share Endpoint.
75-
* `read` - (Defaults to 5 minutes) Used when retrieving the Storage Mover SMB File Share Endpoint.
76-
* `update` - (Defaults to 30 minutes) Used when updating the Storage Mover SMB File Share Endpoint.
77-
* `delete` - (Defaults to 30 minutes) Used when deleting the Storage Mover SMB File Share Endpoint.
76+
* `create` - (Defaults to 30 minutes) Used when creating the Storage Mover SMB File Share Target Endpoint.
77+
* `read` - (Defaults to 5 minutes) Used when retrieving the Storage Mover SMB File Share Target Endpoint.
78+
* `update` - (Defaults to 30 minutes) Used when updating the Storage Mover SMB File Share Target Endpoint.
79+
* `delete` - (Defaults to 30 minutes) Used when deleting the Storage Mover SMB File Share Target Endpoint.
7880

7981
## Import
8082

81-
Storage Mover SMB File Share Endpoint can be imported using the `resource id`, e.g.
83+
Storage Mover SMB File Share Target Endpoints can be imported using the `resource id`, e.g.
8284

8385
```shell
8486
terraform import azurerm_storage_mover_smb_file_share_endpoint.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.StorageMover/storageMovers/storageMover1/endpoints/endpoint1

website/docs/r/storage_mover_target_endpoint.html.markdown

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ description: |-
88

99
# azurerm_storage_mover_target_endpoint
1010

11-
Manages a Storage Mover Target Endpoint.
11+
Manages a Storage Mover **Target Endpoint** for an Azure Storage **blob container** migration destination (as shown in the Azure portal).
12+
13+
-> **Note:** To target an **NFS file share** on Azure Files instead, use [`azurerm_storage_mover_nfs_file_share_target_endpoint`](storage_mover_nfs_file_share_target_endpoint.html). For an **SMB** file share target, use [`azurerm_storage_mover_smb_file_share_endpoint`](storage_mover_smb_file_share_endpoint.html).
1214

1315
## Example Usage
1416

0 commit comments

Comments
 (0)