powerstore_filesystem_snapshot (Resource)
This resource is used to manage the filesystem snapshot entity of PowerStore Array. We can Create, Update and Delete the filesystem snapshot using this resource. We can also import an existing filesystem snapshot from PowerStore array.
Example Usage
/*
Copyright (c) 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 powerstore_filesystem_snapshot/import.tf for more info
# filesystem_id is the required attribute to create file system snapshot.
# name, expiration_timestamp, access_type and description are the optional attributes
# if name is present in the config it cannot be blank("").
# During create operation, if expiration_timestamp is not specified or set to blank(""), snapshot will be created with infinite retention.
# During modify operation, to set infinite retention, expiration_timestamp can be set to blank("").
# To check which attributes of the file system snapshot resource can be updated, please refer Product Guide in the documentation
# To create a file system snapshot, we shall:
# 1. get the id of the filesystem to be snapshotted
data "powerstore_filesystem" "us_east_sales_catalog_fs" {
name = "us_east_sales_catalog_fs"
lifecycle {
postcondition {
condition = length(self.filesystems) == 0
error_message = "Expected a single filesystem for US East sales catalog, but got ${length(self.filesystems)}"
}
}
}
# 2. create an expiration timestamp in the RFC3339 format
resource "time_offset" "us_east_sales_catalog_snapshot_expiration_timestamp" {
// this will set expiration timestamp to 2 years 1 month from the time of creation of the snapshot
offset_years = 2
offset_months = 1
}
# 3. take the snapshot
resource "powerstore_filesystem_snapshot" "us_east_sales_catalog_snapshot" {
name = "us_east_sales_catalog_snapshot"
description = "Snapshot of US East Sales Catalog"
filesystem_id = data.powerstore_filesystem.us_east_sales_catalog_fs.filesystems[0].id
expiration_timestamp = time_offset.us_east_sales_catalog_snapshot_expiration_timestamp.rfc3339
access_type = "Snapshot"
}
After the execution of above resource block, filesystem snapshot would have been created on the PowerStore array. For more information, Please check the terraform state file.
Schema
Required
filesystem_id
(String) ID of the filesystem to take snapshot. Cannot be updated.
Optional
access_type
(String) Access type of the filesystem snapshot. Access type can be ‘Snapshot’ or ‘Protocol’. Cannot be updated.description
(String) Description of the filesystem snapshot.expiration_timestamp
(String) Expiration Timestamp of the filesystem snapshot, if not provided there will no expiration for the snapshot. To remove the expiration timestamp, specify it as an empty string. Only UTC (+Z) format is allowed eg: 2023-05-06T09:01:47Zname
(String) Name of the filesystem snapshot.The default name of the filesystem snapshot is the date and time when the snapshot is taken.
Read-Only
id
(String) The unique identifier of the filesystem snapshot.
Import
Import is supported using the following syntax:
#Copyright (c) 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.
# Below are the steps to import snapshot :
# Step 1 - To import a filesystem snapshot , we need the id of that filesystem snapshot
# Step 2 - To check the id of the filesystem snapshot we can make Get request to filesystem snapshot endpoint. eg. https://10.0.0.1/api/rest/file_system and 'filesystem_type: Snapshot' which will return list of all filesystem snapshots ids.
# Step 3 - Add empty resource block in tf file.
# eg.
# resource "powerstore_filesystem_snapshot" "resource_block_name" {
# (resource arguments)
# }
# Step 4 - Execute the command: terraform import "powerstore_filesystem_snapshot.resource_block_name" "id_of_the_snapshot" (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