powerstore_smb_share (Resource)

This resource is used to manage the smb share entity of PowerStore Array. We can Create, Update and Delete the smb share using this resource. We can also import an existing smb share from PowerStore array.

Example Usage

/*
Copyright (c) 2025 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

# Commands to run this tf file : terraform init && terraform plan && terraform apply
# Create, Update, Delete and Import is supported for this resource

# To create an SMB Share of a filesystem, we shall:
# 1. get the id of the filesystem to be shared over SMB
data "powerstore_filesystem" "sales_catalog" {
  name = "sales_catalog_fs"
  lifecycle {
    postcondition {
      condition     = length(self.filesystems) == 0
      error_message = "Expected a single filesystem for sales catalog, but got ${length(self.filesystems)}"
    }
  }
}

# 2. create an SMB Share from that filesystem
resource "powerstore_smb_share" "sales_catalog_for_2024_march" {
  // Required
  file_system_id = data.powerstore_filesystem.sales_catalog.filesystems[0].id
  name           = "sales_catalog_for_2024_march"
  path           = "/sales_catalog_fs/2024/March"

  // Optional
  description                        = "SMB Share for sales catalog for 2024 March"
  aces                               = [{ "access_level" : "Full", "access_type" : "Allow", "trustee_name" : "Everyone", "trustee_type" : "WellKnown" }]
  is_abe_enabled                     = true
  is_continuous_availability_enabled = true
  is_encryption_enabled              = true
  is_branch_cache_enabled            = true
  offline_availability               = "Manual"
  umask                              = "077"
}

# To expose a snapshot of a filesystem via NFS, we shall:
# 1. create a snapshot of type "Protocol" of the given filesystem
resource "powerstore_filesystem_snapshot" "sales_catalog_snap" {
  name          = "sales_catalog_snap"
  description   = "Snapshot of Sales Catalog Filesystem"
  filesystem_id = data.powerstore_filesystem.sales_catalog.filesystems[0].id
  access_type   = "Protocol"
}

# 2. Expose the snapshot over SMB (here, we are sharing the /2024/March directory from the snapshot)
resource "powerstore_smb_share" "sales_catalog_for_2024_march_snap" {
  file_system_id = powerstore_filesystem_snapshot.sales_catalog_snap.id
  name           = "sales_catalog_for_2024_march_snap"
  path           = "/${powestore_filesystem_snapshot.sales_catalog_snap.name}/2024/March"
  description    = "SMB share of Sales Catalog for 2024 March from snapshot"
}

Schema

Required

  • file_system_id (String) The unique identifier of the file system on which the SMB Share is created.
  • name (String) The name of the SMB Share.
  • path (String) The local path to export relative to the NAS Server.

Optional

  • aces (Attributes Set) To specify the ACL access options. (see below for nested schema)
  • description (String) User defined SMB share description.
  • is_abe_enabled (Boolean) Whether Access-based Enumeration (ABE) is enabled.
  • is_branch_cache_enabled (Boolean) Whether BranchCache optimization is enabled.
  • is_continuous_availability_enabled (Boolean) Whether continuous availability for Server Message Block (SMB) 3.0 is enabled for the SMB Share.
  • is_encryption_enabled (Boolean) Whether encryption for Server Message Block (SMB) 3.0 is enabled at the shared folder level.
  • offline_availability (String) Defines valid states of Offline Availability, where the states are: Manual - Only specified files will be available offline. Documents - All files that users open will be available offline. Programs - Program will preferably run from the offline cache even when connected to the network. All files that users open will be available offline. None - Prevents clients from storing documents and programs in offline cache.
  • umask (String) The default UNIX umask for new files created on the Share.

Read-Only

  • id (String) The unique identifier of the SMB Share.

Nested Schema for aces

Required:

  • access_level (String) The access level.
  • access_type (String) The access type.
  • trustee_name (String) The name of the trustee.
  • trustee_type (String) The type of the trustee.

Import

Import is supported using the following syntax:

#Copyright (c) 2025 Dell Inc., or its subsidiaries. All Rights Reserved.
#
#Licensed under the Mozilla Public License Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
#    http://mozilla.org/MPL/2.0/
#
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.


# Below are the steps to import smb share :
# Step 1 - To import a smb share , we need the id of that smb share 
# Step 2 - To check the id of the smb share we can make use of smb share datasource to read required/all smb share ids. Alternatively, we can make GET request to smb share endpoint. eg. https://10.0.0.1/api/rest/smb_share which will return list of all smb share ids.
# Step 3 - Add empty resource block in tf file. 
# eg. 
# resource "powerstore_smb_share" "resource_block_name" {
  # (resource arguments)
# }
# Step 4 - Execute the command: terraform import "powerstore_smb_share.resource_block_name" "id_of_the_smb_share" (resource_block_name must be taken from step 3 and id must be taken from step 2)
# Step 5 - After successful execution of the command , check the state file