Skip to content

Commit 7a0f24b

Browse files
Add storage mover example and validation test (SMB mount endpoint)
- examples/storage-mover: full example with SMB mount endpoint, validation-test-invalid.tf.example, README Made-with: Cursor
1 parent b9219a7 commit 7a0f24b

4 files changed

Lines changed: 172 additions & 0 deletions

File tree

examples/storage-mover/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Storage Mover examples (SMB mount endpoint)
2+
3+
Creates: `azurerm_storage_mover`, target endpoint, source endpoint, **SMB mount endpoint**, project, job definition.
4+
5+
## Usage
6+
7+
1. Build: `make build` (from repo root)
8+
2. Use local provider via `dev_overrides` in `~/.terraformrc`
9+
3. Set ARM_* env vars, then: `terraform init && terraform plan`
10+
11+
Set `smb_host` and `smb_share_name` (and optionally credentials) for apply.
12+
13+
## Validation
14+
15+
Copy `validation-test-invalid.tf.example` to `validation-test-invalid.tf` and run `terraform plan` to verify invalid inputs are rejected.

examples/storage-mover/main.tf

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Storage Mover example - SMB mount endpoint branch.
2+
# Run: make build && terraform init && terraform plan
3+
4+
terraform {
5+
required_providers {
6+
azurerm = {
7+
source = "hashicorp/azurerm"
8+
version = ">= 4.0"
9+
}
10+
}
11+
}
12+
13+
provider "azurerm" {
14+
features {}
15+
}
16+
17+
resource "azurerm_resource_group" "example" {
18+
name = "acctest-rg-storage-mover-example"
19+
location = var.primary_location
20+
}
21+
22+
resource "azurerm_storage_mover" "example" {
23+
name = "acctest-ssm-example"
24+
resource_group_name = azurerm_resource_group.example.name
25+
location = azurerm_resource_group.example.location
26+
description = "Example Storage Mover"
27+
}
28+
29+
resource "azurerm_storage_account" "example" {
30+
name = "acctestsa${substr(md5(azurerm_resource_group.example.name), 0, 8)}"
31+
resource_group_name = azurerm_resource_group.example.name
32+
location = azurerm_resource_group.example.location
33+
account_tier = "Standard"
34+
account_replication_type = "LRS"
35+
allow_nested_items_to_be_public = true
36+
}
37+
38+
resource "azurerm_storage_container" "example" {
39+
name = "acctest-container"
40+
storage_account_name = azurerm_storage_account.example.name
41+
container_access_type = "blob"
42+
}
43+
44+
resource "azurerm_storage_mover_target_endpoint" "example" {
45+
name = "acctest-smte-example"
46+
storage_mover_id = azurerm_storage_mover.example.id
47+
storage_account_id = azurerm_storage_account.example.id
48+
storage_container_name = azurerm_storage_container.example.name
49+
description = "Example target blob container endpoint"
50+
}
51+
52+
resource "azurerm_storage_mover_source_endpoint" "example" {
53+
name = "acctest-smse-example"
54+
storage_mover_id = azurerm_storage_mover.example.id
55+
host = var.nfs_host
56+
export = "/"
57+
nfs_version = "NFSv4"
58+
description = "Example NFS source endpoint"
59+
}
60+
61+
resource "azurerm_storage_mover_smb_mount_endpoint" "example" {
62+
name = "acctest-smsme-example"
63+
storage_mover_id = azurerm_storage_mover.example.id
64+
host = var.smb_host
65+
share_name = var.smb_share_name
66+
description = "Example SMB mount endpoint"
67+
}
68+
69+
resource "azurerm_storage_mover_project" "example" {
70+
name = "acctest-smp-example"
71+
storage_mover_id = azurerm_storage_mover.example.id
72+
description = "Example Storage Mover project"
73+
}
74+
75+
resource "azurerm_storage_mover_job_definition" "example" {
76+
name = "acctest-smjd-example"
77+
storage_mover_project_id = azurerm_storage_mover_project.example.id
78+
source_name = azurerm_storage_mover_source_endpoint.example.name
79+
target_name = azurerm_storage_mover_target_endpoint.example.name
80+
copy_mode = "Additive"
81+
description = "Example job definition"
82+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Validation test: invalid inputs (SMB mount endpoint branch).
2+
# Copy to validation-test-invalid.tf and run: terraform plan
3+
# Requires main.tf to provide dependencies.
4+
5+
resource "azurerm_storage_mover_target_endpoint" "invalid_name" {
6+
name = "acctest-smte-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
7+
storage_mover_id = azurerm_storage_mover.example.id
8+
storage_account_id = azurerm_storage_account.example.id
9+
storage_container_name = azurerm_storage_container.example.name
10+
}
11+
12+
resource "azurerm_storage_mover_project" "invalid_storage_mover_id" {
13+
name = "valid-project-name"
14+
storage_mover_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Storage/storageAccounts/wrong"
15+
}
16+
17+
resource "azurerm_storage_mover_smb_mount_endpoint" "invalid_storage_mover_id" {
18+
name = "valid-sme-name"
19+
storage_mover_id = "not-a-valid-storage-mover-id"
20+
host = "192.168.0.1"
21+
share_name = "share1"
22+
}
23+
24+
resource "azurerm_storage_mover_smb_mount_endpoint" "invalid_host" {
25+
name = "valid-sme-name-2"
26+
storage_mover_id = azurerm_storage_mover.example.id
27+
host = ""
28+
share_name = "share1"
29+
}
30+
31+
resource "azurerm_storage_mover_target_endpoint" "invalid_container_name" {
32+
name = "valid-te-name"
33+
storage_mover_id = azurerm_storage_mover.example.id
34+
storage_account_id = azurerm_storage_account.example.id
35+
storage_container_name = "x"
36+
}
37+
38+
resource "azurerm_storage_mover_job_definition" "invalid_project_id" {
39+
name = "valid-jd-name"
40+
storage_mover_project_id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.StorageMover/storageMovers/mover/endpoints/wrong"
41+
source_name = azurerm_storage_mover_source_endpoint.example.name
42+
target_name = azurerm_storage_mover_target_endpoint.example.name
43+
copy_mode = "Additive"
44+
}
45+
46+
resource "azurerm_storage_mover_job_definition" "invalid_copy_mode" {
47+
name = "valid-jd-name-2"
48+
storage_mover_project_id = azurerm_storage_mover_project.example.id
49+
source_name = azurerm_storage_mover_source_endpoint.example.name
50+
target_name = azurerm_storage_mover_target_endpoint.example.name
51+
copy_mode = "InvalidMode"
52+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
variable "primary_location" {
2+
type = string
3+
default = "East US"
4+
description = "Primary Azure region for resources"
5+
}
6+
7+
variable "nfs_host" {
8+
type = string
9+
default = "192.168.0.1"
10+
description = "Host for NFS source endpoint"
11+
}
12+
13+
variable "smb_host" {
14+
type = string
15+
default = "192.168.0.2"
16+
description = "Host for SMB mount endpoint (use real SMB server for apply)"
17+
}
18+
19+
variable "smb_share_name" {
20+
type = string
21+
default = "share1"
22+
description = "SMB share name for mount endpoint"
23+
}

0 commit comments

Comments
 (0)