powerflex_sdc_volumes_mapping (Resource)

This resource can be used to map/unmap volumes to an SDC on a PowerFlex array. User can import an existing SDC and map volumes to it.

Caution: SDC Volume mapping creation or update is not atomic. In case of partially completed create operations, terraform can mark the resource as tainted. One can manually remove the taint and try applying the configuration (after making necessary adjustments). If the taint is not removed, terraform will destroy and recreate the resource.

Note: Either id or name is required. But not both.

Note: Either volume_id or volume_name is required. But not both.

Example Usage

/*
Copyright (c) 2023-2024 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.
*/

# Command to run this tf file : terraform init && terraform plan && terraform apply.
# Create, Update, Delete is supported for this resource.
# To import, check import.sh for more info.
# To create/update, either SDC ID or SDC name must be provided.
# volume_list attribute is optional. 
# To check which attributes of the sdc_volumes_mappping resource can be updated, please refer Product Guide in the documentation

resource "powerflex_sdc_volumes_mapping" "mapping-test" {
  # SDC id
  id = "e3ce1fb600000001"
  volume_list = [
    {
      # id of the volume which needs to be mapped. 
      # either volume_id or volume_name can be used.
      volume_id = "edb2059700000002"

      # Valid values are 0 or integers greater than 10
      limit_iops = 140

      # Default value is 0
      limit_bw_in_mbps = 19

      access_mode = "ReadOnly" # ReadOnly/ReadWrite/NoAccess
    },
    {
      volume_name      = "terraform-vol"
      access_mode      = "ReadWrite"
      limit_iops       = 120
      limit_bw_in_mbps = 25
    }
  ]
}

# To unmap all the volumes mapped to SDC, below config can be used. After successful execution, all the volumes mapped to SDC will be unmapped.

resource "powerflex_sdc_volumes_mapping" "mapping-test" {
  id          = "e3ce1fb600000001"
  volume_list = []
}

After the execution of above resource block, two volumes would have been unmapped from SDC on the PowerFlex array. For more information, please check the terraform state file

Schema

Optional

  • id (String) The ID of the SDC.
  • name (String) The name of the SDC.
  • volume_list (Attributes List) List of volumes mapped to SDC. At least one of volume_id and volume_name is required. (see below for nested schema)

Nested Schema for volume_list

Optional:

  • access_mode (String) The Access Mode of the SDC. Valid values are ReadOnly, ReadWrite and NoAccess. Default value is ReadOnly.
  • limit_bw_in_mbps (Number) Bandwidth limit in MBPS. 0 represents unlimited bandwith. Default value is 0.
  • limit_iops (Number) IOPS limit. Valid values are 0 or integers greater than 10. 0 represents unlimited IOPS. Default value is 0.
  • volume_id (String) The ID of the volume.
  • volume_name (String) The name of the volume.

Import

Import is supported using the following syntax:

# Below are the steps to import sdc along with mapped volumes :
# Step 1 - To import a sdc , we need the id of that sdc
# Step 2 - To check the id of the sdc we can make use of sdc datasource . Please refer sdc_datasource.tf for more info.
# Step 3 - create a tf file with empty resource block . Refer the example below.
# Example :
# resource "powerflex_sdc_volumes_mapping" "resource_block_name" {
# }
# Step 4 - execute the command: terraform import "powerflex_sdc_volumes_mapping.resource_block_name" "id_of_the_sdc" (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.

# /*
# Copyright (c) 2023-2024 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.
# */

# import using SDC id
terraform import powerflex_sdc_volumes_mapping.sdc_mapping_import_by_id "<id>"
  1. This will import the SDC instance with specified ID into your Terraform state.
  2. After successful import, you can run terraform state list to ensure the resource has been imported successfully.
  3. Now, you can fill in the resource block with the appropriate arguments and settings that match the imported resource’s real-world configuration.
  4. Execute terraform plan to see if your configuration and the imported resource are in sync. Make adjustments if needed.
  5. Finally, execute terraform apply to bring the resource fully under Terraform’s management.
  6. Now, the resource which was not part of terraform became part of Terraform managed infrastructure.