Skip to content

Commit 7167013

Browse files
storage_mover: rename to nfs_file_share_target_endpoint; identity; guide error msg; docs Target Endpoint; inline tests
Made-with: Cursor
1 parent 53ee380 commit 7167013

File tree

5 files changed

+85
-71
lines changed

5 files changed

+85
-71
lines changed

internal/services/storagemover/registration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (r Registration) Resources() []sdk.Resource {
4242
return []sdk.Resource{
4343
StorageMoverResource{},
4444
StorageMoverAgentResource{},
45-
StorageMoverNfsFileShareEndpointResource{},
45+
StorageMoverNfsFileShareTargetEndpointResource{},
4646
StorageMoverSourceEndpointResource{},
4747
StorageMoverTargetEndpointResource{},
4848
StorageMoverProjectResource{},

internal/services/storagemover/storage_mover_nfs_file_share_endpoint_resource.go renamed to internal/services/storagemover/storage_mover_nfs_file_share_target_endpoint_resource.go

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/hashicorp/go-azure-helpers/lang/pointer"
1212
"github.com/hashicorp/go-azure-helpers/lang/response"
1313
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
14+
"github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids"
1415
"github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2025-07-01/endpoints"
1516
"github.com/hashicorp/go-azure-sdk/resource-manager/storagemover/2025-07-01/storagemovers"
1617
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
@@ -20,31 +21,38 @@ import (
2021
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
2122
)
2223

23-
type StorageMoverNfsFileShareEndpointModel struct {
24+
type StorageMoverNfsFileShareTargetEndpointModel struct {
2425
Name string `tfschema:"name"`
2526
StorageMoverId string `tfschema:"storage_mover_id"`
2627
StorageAccountId string `tfschema:"storage_account_id"`
2728
FileShareName string `tfschema:"file_share_name"`
2829
Description string `tfschema:"description"`
2930
}
3031

31-
type StorageMoverNfsFileShareEndpointResource struct{}
32+
type StorageMoverNfsFileShareTargetEndpointResource struct{}
3233

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

35-
func (r StorageMoverNfsFileShareEndpointResource) ResourceType() string {
36-
return "azurerm_storage_mover_nfs_file_share_endpoint"
39+
func (r StorageMoverNfsFileShareTargetEndpointResource) ResourceType() string {
40+
return "azurerm_storage_mover_nfs_file_share_target_endpoint"
3741
}
3842

39-
func (r StorageMoverNfsFileShareEndpointResource) ModelObject() interface{} {
40-
return &StorageMoverNfsFileShareEndpointModel{}
43+
func (r StorageMoverNfsFileShareTargetEndpointResource) ModelObject() interface{} {
44+
return &StorageMoverNfsFileShareTargetEndpointModel{}
4145
}
4246

43-
func (r StorageMoverNfsFileShareEndpointResource) IDValidationFunc() pluginsdk.SchemaValidateFunc {
47+
func (r StorageMoverNfsFileShareTargetEndpointResource) IDValidationFunc() pluginsdk.SchemaValidateFunc {
4448
return endpoints.ValidateEndpointID
4549
}
4650

47-
func (r StorageMoverNfsFileShareEndpointResource) Arguments() map[string]*pluginsdk.Schema {
51+
func (r StorageMoverNfsFileShareTargetEndpointResource) Identity() resourceids.ResourceId {
52+
return &endpoints.EndpointId{}
53+
}
54+
55+
func (r StorageMoverNfsFileShareTargetEndpointResource) Arguments() map[string]*pluginsdk.Schema {
4856
return map[string]*pluginsdk.Schema{
4957
"name": {
5058
Type: pluginsdk.TypeString,
@@ -82,15 +90,15 @@ func (r StorageMoverNfsFileShareEndpointResource) Arguments() map[string]*plugin
8290
}
8391
}
8492

85-
func (r StorageMoverNfsFileShareEndpointResource) Attributes() map[string]*pluginsdk.Schema {
93+
func (r StorageMoverNfsFileShareTargetEndpointResource) Attributes() map[string]*pluginsdk.Schema {
8694
return map[string]*pluginsdk.Schema{}
8795
}
8896

89-
func (r StorageMoverNfsFileShareEndpointResource) Create() sdk.ResourceFunc {
97+
func (r StorageMoverNfsFileShareTargetEndpointResource) Create() sdk.ResourceFunc {
9098
return sdk.ResourceFunc{
9199
Timeout: 30 * time.Minute,
92100
Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error {
93-
var model StorageMoverNfsFileShareEndpointModel
101+
var model StorageMoverNfsFileShareTargetEndpointModel
94102
if err := metadata.Decode(&model); err != nil {
95103
return fmt.Errorf("decoding: %+v", err)
96104
}
@@ -104,7 +112,7 @@ func (r StorageMoverNfsFileShareEndpointResource) Create() sdk.ResourceFunc {
104112
id := endpoints.NewEndpointID(storageMoverId.SubscriptionId, storageMoverId.ResourceGroupName, storageMoverId.StorageMoverName, model.Name)
105113
existing, err := client.Get(ctx, id)
106114
if err != nil && !response.WasNotFound(existing.HttpResponse) {
107-
return fmt.Errorf("checking for existing %s: %+v", id, err)
115+
return fmt.Errorf("checking for presence of existing %s: %+v", id, err)
108116
}
109117

110118
if !response.WasNotFound(existing.HttpResponse) {
@@ -130,12 +138,15 @@ func (r StorageMoverNfsFileShareEndpointResource) Create() sdk.ResourceFunc {
130138
}
131139

132140
metadata.SetID(id)
133-
return nil
141+
if err := pluginsdk.SetResourceIdentityData(metadata.ResourceData, &id); err != nil {
142+
return err
143+
}
144+
return metadata.Encode(&model)
134145
},
135146
}
136147
}
137148

138-
func (r StorageMoverNfsFileShareEndpointResource) Update() sdk.ResourceFunc {
149+
func (r StorageMoverNfsFileShareTargetEndpointResource) Update() sdk.ResourceFunc {
139150
return sdk.ResourceFunc{
140151
Timeout: 30 * time.Minute,
141152
Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error {
@@ -146,7 +157,7 @@ func (r StorageMoverNfsFileShareEndpointResource) Update() sdk.ResourceFunc {
146157
return err
147158
}
148159

149-
var model StorageMoverNfsFileShareEndpointModel
160+
var model StorageMoverNfsFileShareTargetEndpointModel
150161
if err := metadata.Decode(&model); err != nil {
151162
return fmt.Errorf("decoding: %+v", err)
152163
}
@@ -177,7 +188,7 @@ func (r StorageMoverNfsFileShareEndpointResource) Update() sdk.ResourceFunc {
177188
}
178189
}
179190

180-
func (r StorageMoverNfsFileShareEndpointResource) Read() sdk.ResourceFunc {
191+
func (r StorageMoverNfsFileShareTargetEndpointResource) Read() sdk.ResourceFunc {
181192
return sdk.ResourceFunc{
182193
Timeout: 5 * time.Minute,
183194
Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error {
@@ -197,7 +208,7 @@ func (r StorageMoverNfsFileShareEndpointResource) Read() sdk.ResourceFunc {
197208
return fmt.Errorf("retrieving %s: %+v", *id, err)
198209
}
199210

200-
state := StorageMoverNfsFileShareEndpointModel{
211+
state := StorageMoverNfsFileShareTargetEndpointModel{
201212
Name: id.EndpointName,
202213
StorageMoverId: storagemovers.NewStorageMoverID(id.SubscriptionId, id.ResourceGroupName, id.StorageMoverName).ID(),
203214
}
@@ -211,12 +222,15 @@ func (r StorageMoverNfsFileShareEndpointResource) Read() sdk.ResourceFunc {
211222
}
212223
}
213224

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

219-
func (r StorageMoverNfsFileShareEndpointResource) Delete() sdk.ResourceFunc {
233+
func (r StorageMoverNfsFileShareTargetEndpointResource) Delete() sdk.ResourceFunc {
220234
return sdk.ResourceFunc{
221235
Timeout: 30 * time.Minute,
222236
Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error {

internal/services/storagemover/storage_mover_nfs_file_share_endpoint_resource_test.go renamed to internal/services/storagemover/storage_mover_nfs_file_share_target_endpoint_resource_test.go

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ import (
1717
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
1818
)
1919

20-
type StorageMoverNfsFileShareEndpointTestResource struct{}
20+
type StorageMoverNfsFileShareTargetEndpointTestResource struct{}
2121

22-
func TestAccStorageMoverNfsFileShareEndpoint_basic(t *testing.T) {
23-
data := acceptance.BuildTestData(t, "azurerm_storage_mover_nfs_file_share_endpoint", "test")
24-
r := StorageMoverNfsFileShareEndpointTestResource{}
22+
func TestAccStorageMoverNfsFileShareTargetEndpoint_basic(t *testing.T) {
23+
data := acceptance.BuildTestData(t, "azurerm_storage_mover_nfs_file_share_target_endpoint", "test")
24+
r := StorageMoverNfsFileShareTargetEndpointTestResource{}
2525
data.ResourceTest(t, r, []acceptance.TestStep{
2626
{
2727
Config: r.basic(data),
@@ -33,9 +33,9 @@ func TestAccStorageMoverNfsFileShareEndpoint_basic(t *testing.T) {
3333
})
3434
}
3535

36-
func TestAccStorageMoverNfsFileShareEndpoint_requiresImport(t *testing.T) {
37-
data := acceptance.BuildTestData(t, "azurerm_storage_mover_nfs_file_share_endpoint", "test")
38-
r := StorageMoverNfsFileShareEndpointTestResource{}
36+
func TestAccStorageMoverNfsFileShareTargetEndpoint_requiresImport(t *testing.T) {
37+
data := acceptance.BuildTestData(t, "azurerm_storage_mover_nfs_file_share_target_endpoint", "test")
38+
r := StorageMoverNfsFileShareTargetEndpointTestResource{}
3939
data.ResourceTest(t, r, []acceptance.TestStep{
4040
{
4141
Config: r.basic(data),
@@ -47,9 +47,9 @@ func TestAccStorageMoverNfsFileShareEndpoint_requiresImport(t *testing.T) {
4747
})
4848
}
4949

50-
func TestAccStorageMoverNfsFileShareEndpoint_complete(t *testing.T) {
51-
data := acceptance.BuildTestData(t, "azurerm_storage_mover_nfs_file_share_endpoint", "test")
52-
r := StorageMoverNfsFileShareEndpointTestResource{}
50+
func TestAccStorageMoverNfsFileShareTargetEndpoint_complete(t *testing.T) {
51+
data := acceptance.BuildTestData(t, "azurerm_storage_mover_nfs_file_share_target_endpoint", "test")
52+
r := StorageMoverNfsFileShareTargetEndpointTestResource{}
5353
data.ResourceTest(t, r, []acceptance.TestStep{
5454
{
5555
Config: r.complete(data),
@@ -61,9 +61,9 @@ func TestAccStorageMoverNfsFileShareEndpoint_complete(t *testing.T) {
6161
})
6262
}
6363

64-
func TestAccStorageMoverNfsFileShareEndpoint_update(t *testing.T) {
65-
data := acceptance.BuildTestData(t, "azurerm_storage_mover_nfs_file_share_endpoint", "test")
66-
r := StorageMoverNfsFileShareEndpointTestResource{}
64+
func TestAccStorageMoverNfsFileShareTargetEndpoint_update(t *testing.T) {
65+
data := acceptance.BuildTestData(t, "azurerm_storage_mover_nfs_file_share_target_endpoint", "test")
66+
r := StorageMoverNfsFileShareTargetEndpointTestResource{}
6767
data.ResourceTest(t, r, []acceptance.TestStep{
6868
{
6969
Config: r.complete(data),
@@ -82,7 +82,7 @@ func TestAccStorageMoverNfsFileShareEndpoint_update(t *testing.T) {
8282
})
8383
}
8484

85-
func (r StorageMoverNfsFileShareEndpointTestResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
85+
func (r StorageMoverNfsFileShareTargetEndpointTestResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
8686
id, err := endpoints.ParseEndpointID(state.ID)
8787
if err != nil {
8888
return nil, err
@@ -99,7 +99,7 @@ func (r StorageMoverNfsFileShareEndpointTestResource) Exists(ctx context.Context
9999
return pointer.To(resp.Model != nil), nil
100100
}
101101

102-
func (r StorageMoverNfsFileShareEndpointTestResource) template(data acceptance.TestData) string {
102+
func (r StorageMoverNfsFileShareTargetEndpointTestResource) template(data acceptance.TestData) string {
103103
return fmt.Sprintf(`
104104
resource "azurerm_resource_group" "test" {
105105
name = "acctest-rg-%d"
@@ -130,72 +130,68 @@ resource "azurerm_storage_mover" "test" {
130130
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomString, data.RandomInteger)
131131
}
132132

133-
func (r StorageMoverNfsFileShareEndpointTestResource) basic(data acceptance.TestData) string {
134-
template := r.template(data)
133+
func (r StorageMoverNfsFileShareTargetEndpointTestResource) basic(data acceptance.TestData) string {
135134
return fmt.Sprintf(`
136135
provider "azurerm" {
137136
features {}
138137
}
139138
140139
%s
141140
142-
resource "azurerm_storage_mover_nfs_file_share_endpoint" "test" {
141+
resource "azurerm_storage_mover_nfs_file_share_target_endpoint" "test" {
143142
name = "acctest-smnfse-%d"
144143
storage_mover_id = azurerm_storage_mover.test.id
145144
storage_account_id = azurerm_storage_account.test.id
146145
file_share_name = azurerm_storage_share.test.name
147146
}
148-
`, template, data.RandomInteger)
147+
`, r.template(data), data.RandomInteger)
149148
}
150149

151-
func (r StorageMoverNfsFileShareEndpointTestResource) requiresImport(data acceptance.TestData) string {
152-
config := r.basic(data)
150+
func (r StorageMoverNfsFileShareTargetEndpointTestResource) requiresImport(data acceptance.TestData) string {
153151
return fmt.Sprintf(`
154152
%s
155153
156-
resource "azurerm_storage_mover_nfs_file_share_endpoint" "import" {
157-
name = azurerm_storage_mover_nfs_file_share_endpoint.test.name
154+
resource "azurerm_storage_mover_nfs_file_share_target_endpoint" "import" {
155+
name = azurerm_storage_mover_nfs_file_share_target_endpoint.test.name
158156
storage_mover_id = azurerm_storage_mover.test.id
159157
storage_account_id = azurerm_storage_account.test.id
160158
file_share_name = azurerm_storage_share.test.name
161159
}
162-
`, config)
160+
`, r.basic(data))
163161
}
164162

165-
func (r StorageMoverNfsFileShareEndpointTestResource) complete(data acceptance.TestData) string {
166-
template := r.template(data)
163+
func (r StorageMoverNfsFileShareTargetEndpointTestResource) complete(data acceptance.TestData) string {
167164
return fmt.Sprintf(`
168165
provider "azurerm" {
169166
features {}
170167
}
171168
172169
%s
173170
174-
resource "azurerm_storage_mover_nfs_file_share_endpoint" "test" {
171+
resource "azurerm_storage_mover_nfs_file_share_target_endpoint" "test" {
175172
name = "acctest-smnfse-%d"
176173
storage_mover_id = azurerm_storage_mover.test.id
177174
storage_account_id = azurerm_storage_account.test.id
178175
file_share_name = azurerm_storage_share.test.name
179176
description = "Example NFS File Share Endpoint Description"
180177
}
181-
`, template, data.RandomInteger)
178+
`, r.template(data), data.RandomInteger)
182179
}
183180

184-
func (r StorageMoverNfsFileShareEndpointTestResource) update(data acceptance.TestData) string {
185-
template := r.template(data)
181+
func (r StorageMoverNfsFileShareTargetEndpointTestResource) update(data acceptance.TestData) string {
186182
return fmt.Sprintf(`
187183
provider "azurerm" {
188184
features {}
189185
}
190186
191187
%s
192188
193-
resource "azurerm_storage_mover_nfs_file_share_endpoint" "test" {
189+
resource "azurerm_storage_mover_nfs_file_share_target_endpoint" "test" {
194190
name = "acctest-smnfse-%d"
195191
storage_mover_id = azurerm_storage_mover.test.id
196192
storage_account_id = azurerm_storage_account.test.id
197193
file_share_name = azurerm_storage_share.test.name
198194
description = "Updated NFS File Share Endpoint Description"
199195
}
200-
`, template, data.RandomInteger)
196+
`, r.template(data), data.RandomInteger)
201197
}

website/docs/r/storage_mover_nfs_file_share_endpoint.html.markdown renamed to website/docs/r/storage_mover_nfs_file_share_target_endpoint.html.markdown

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
---
22
subcategory: "Storage Mover"
33
layout: "azurerm"
4-
page_title: "Azure Resource Manager: azurerm_storage_mover_nfs_file_share_endpoint"
4+
page_title: "Azure Resource Manager: azurerm_storage_mover_nfs_file_share_target_endpoint"
55
description: |-
6-
Manages a Storage Mover NFS File Share Endpoint.
6+
Manages a Storage Mover NFS File Share Target Endpoint.
77
---
88

9-
# azurerm_storage_mover_nfs_file_share_endpoint
9+
# azurerm_storage_mover_nfs_file_share_target_endpoint
1010

11-
Manages a Storage Mover NFS File Share Endpoint.
11+
Manages a Storage Mover **NFS File Share Target Endpoint** (an endpoint that targets an Azure Files NFS 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.
1214

1315
## Example Usage
1416

@@ -40,50 +42,50 @@ resource "azurerm_storage_mover" "example" {
4042
location = "West Europe"
4143
}
4244
43-
resource "azurerm_storage_mover_nfs_file_share_endpoint" "example" {
45+
resource "azurerm_storage_mover_nfs_file_share_target_endpoint" "example" {
4446
name = "example-nfse"
4547
storage_mover_id = azurerm_storage_mover.example.id
4648
storage_account_id = azurerm_storage_account.example.id
4749
file_share_name = azurerm_storage_share.example.name
48-
description = "Example NFS File Share Endpoint"
50+
description = "Example NFS File Share Target Endpoint"
4951
}
5052
```
5153

5254
## Arguments Reference
5355

5456
The following arguments are supported:
5557

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

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

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

62-
* `file_share_name` - (Required) Specifies the name of the NFS File Share for this Storage Mover NFS File Share Endpoint. Changing this forces a new resource to be created.
64+
* `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.
6365

64-
* `description` - (Optional) Specifies a description for the Storage Mover NFS File Share Endpoint.
66+
* `description` - (Optional) A description for this Target Endpoint.
6567

6668
## Attributes Reference
6769

6870
In addition to the Arguments listed above - the following Attributes are exported:
6971

70-
* `id` - The ID of the Storage Mover NFS File Share Endpoint.
72+
* `id` - The ID of the Storage Mover NFS File Share Target Endpoint.
7173

7274
## Timeouts
7375

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

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

8183
## Import
8284

83-
Storage Mover NFS File Share Endpoint can be imported using the `resource id`, e.g.
85+
Storage Mover NFS File Share Target Endpoints can be imported using the `resource id`, e.g.
8486

8587
```shell
86-
terraform import azurerm_storage_mover_nfs_file_share_endpoint.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.StorageMover/storageMovers/storageMover1/endpoints/endpoint1
88+
terraform import azurerm_storage_mover_nfs_file_share_target_endpoint.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resourceGroup1/providers/Microsoft.StorageMover/storageMovers/storageMover1/endpoints/endpoint1
8789
```
8890

8991
## API Providers

0 commit comments

Comments
 (0)