powerflex_snapshot (Resource)

This resource is used to manage the Snapshot of volumes on PowerFlex Array. We can Create, Update and Delete the snapshots using this resource. We can also import an existing snapshot from PowerFlex array.

Caution: Snapshot 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 volume_name or volume_id is required. But not both. In case of partial create/update operation, retention will not be set.

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.
*/

# Commands to run this tf file : terraform init && terraform plan && terraform apply
# Create, Update, Delete is supported for this resource
# To import , check snapshot_resource_import.tf for more info
# To create / update, either volume_id or volume_name must be provided
# name is the required parameter to create or update
# other  atrributes like : access_mode, size, capacity_unit, lock_auto_snapshot, desired_retention, retention_unit, remove_mode are optional 
# To check which attributes of the snapshot can be updated, please refer Product Guide in the documentation

# Example for creating snapshot with mandatory params. After successful execution, snapshot will be created of the same size as volume.
resource "powerflex_snapshot" "snapshots-create" {
  name      = "snapshots-create"
  volume_id = "4577c84000000120"
}

# Example for creating snapshot with optional params. After successful execution, snapshot will be created with the specified size.
resource "powerflex_snapshot" "snapshots-create-01" {
  name          = "snapshots-create-epsilon"
  volume_id     = "4577c84000000120"
  access_mode   = "ReadWrite" # ReadOnly/ReadWrite
  size          = 16
  capacity_unit = "GB"                    # GB/TB
  remove_mode   = "INCLUDING_DESCENDANTS" # INCLUDING_DESCENDANTS/ONLY_ME
}


# General guidlines for furnishing this resource block 
# resource "powerflex_snapshot" "snapshots-create-1" {
# 	name = "<snapshot name>"
# 	volume_name = "<volume name>"
# 	access_mode = "<access mode options are ReadOnly/ReadWrite, default value ReadOnly>"
# 	size = "<size[int] associated with capacity unit>"
# 	capacity_unit =  "<capacity unit options are gb/tb, default value gb>"
# 	lock_auto_snapshot = "<lock auto snapshot, snapshot which are created by snapshot policy can be locked.>"
# 	desired_retention = "<desired retention[int] associated with retention unit>"
# 	retention_unit = "<retention unit options are hours/days, default value hours>"
# 	remove_mode = "<remove mode options are ONLY_ME/INCLUDING_DESCENDANTS, default value ONLY_ME>"
# }

After the execution of above resource block, snapshot would have been created on the PowerFlex array. For more information, please check the terraform state file.

Schema

Required

  • name (String) The name of the snapshot.

Optional

  • access_mode (String) The Access mode of snapshot. Valid values are ReadOnly and ReadWrite. Default value is ReadOnly.
  • capacity_unit (String) Unit of capacity of the volume. Must be one of GB and TB. Default value is GB.
  • desired_retention (Number) The minimum amount of time that the snapshot should be retained on the array starting at the time of apply. The unit is defined by retention_unit. Cannot be decreased.
  • lock_auto_snapshot (Boolean) lock auto snapshot
  • remove_mode (String) Remove mode of the snapshot. Valid values are ONLY_ME and INCLUDING_DESCENDANTS. Default value is ONLY_ME.
  • retention_unit (String) Retention unit of the snapshot. Valid values are hours and days. Default value is hours.
  • size (Number) Size of the snapshot. The unit of size is defined by capacity_unit. The storage capacity of a snapshot must be a multiple of 8GB and cannot be decreased.
  • volume_id (String) The ID of the volume from which snapshot is to be created. Conflicts with volume_name. Cannot be updated.
  • volume_name (String) The volume name for which snapshot is created. Conflicts with volume_id. Cannot be updated.

Read-Only

  • id (String) The ID of the snapshot.
  • retention_in_min (String) retention of snapshot in min
  • size_in_kb (Number) Size in KB

Import

Import is supported using the following syntax:

# /*
# 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 Snapshot by it's id
terraform import powerflex_snapshot.ss_data "<id>"
  1. This will import the snapshot 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.