Skip to content

Commit

Permalink
examples for protection policy
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroon-Dweikat-Ntx committed Jan 21, 2025
1 parent eedcab6 commit ada2101
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 0 deletions.
185 changes: 185 additions & 0 deletions examples/protection_policy_v2/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
terraform{
required_providers {
nutanix = {
source = "nutanix/nutanix"
version = "2.0.0"
}
}
}

#defining nutanix configuration
provider "nutanix"{
username = var.nutanix_username
password = var.nutanix_password
endpoint = var.nutanix_endpoint
port = 9440
insecure = true
}

// Create Protection Policy - Synchronous
resource "nutanix_protection_policy_v2" "pp_sync"{
name = "pp_example_1"

replication_configurations {
source_location_label = "source"
remote_location_label = "target"
schedule {
recovery_point_objective_time_seconds = 0
recovery_point_type = "CRASH_CONSISTENT"
sync_replication_auto_suspend_timeout_seconds = 10
}
}
replication_configurations {
source_location_label = "target"
remote_location_label = "source"
schedule {
recovery_point_objective_time_seconds = 0
recovery_point_type = "CRASH_CONSISTENT"
sync_replication_auto_suspend_timeout_seconds = 10
}
}

replication_locations {
domain_manager_ext_id = "domain_manager_ext_id_local"
label = "source"
is_primary = true
}
replication_locations {
domain_manager_ext_id = "domain_manager_ext_id_remote"
label = "target"
is_primary = false
}

category_ids = ["<category_ids>"]
}



// Create Protection Policy - Linear Retention
resource "nutanix_protection_policy_v2" "pp_liner"{
name = "pp_example_2"

replication_configurations {
source_location_label = "source"
remote_location_label = "target"
schedule {
recovery_point_objective_time_seconds = 0
recovery_point_type = "CRASH_CONSISTENT"
retention {
linear_retention {
local = 1
remote = 1
}
}
}
}
replication_configurations {
source_location_label = "target"
remote_location_label = "source"
schedule {
recovery_point_objective_time_seconds = 0
recovery_point_type = "CRASH_CONSISTENT"
retention {
linear_retention {
local = 1
remote = 1
}
}
}
}

replication_locations {
domain_manager_ext_id = "domain_manager_ext_id_local"
label = "source"
is_primary = true
}
replication_locations {
domain_manager_ext_id = "domain_manager_ext_id_remote"
label = "target"
is_primary = false
}

category_ids = ["<category_ids>"]
}

// Create Protection Policy - Auto Rollup Retention
resource "nutanix_protection_policy_v2" "pp_auto"{
name = "pp_example_3"

replication_configurations {
source_location_label = "source"
remote_location_label = "target"
schedule {
recovery_point_objective_time_seconds = 0
recovery_point_type = "CRASH_CONSISTENT"
sync_replication_auto_suspend_timeout_seconds = 20
start_time = "18h:10m"
retention {
auto_rollup_retention {
local {
snapshot_interval_type = "WEEKLY"
frequency = 2
}
remote {
snapshot_interval_type = "DAILY"
frequency = 1
}
}
}
}
}
replication_configurations {
source_location_label = "target"
remote_location_label = "source"
schedule {
recovery_point_objective_time_seconds = 0
recovery_point_type = "CRASH_CONSISTENT"
start_time = "18h:10m"
retention {
auto_rollup_retention {
local {
snapshot_interval_type = "DAILY"
frequency = 1
}
remote {
snapshot_interval_type = "WEEKLY"
frequency = 2
}
}
}
}
}

replication_locations {
domain_manager_ext_id = "domain_manager_ext_id_local"
label = "source"
is_primary = true
}
replication_locations {
domain_manager_ext_id = "domain_manager_ext_id_remote"
label = "target"
is_primary = false
}

category_ids = ["<category_ids>"]
}


// List Protection Policies
data "nutanix_protection_policies_v2" "protectiojn-policies" {}

// with filter
data "nutanix_protection_policies_v2" "pp-filter" {
filter = "name eq 'pp_example_2'"
}

// with limit
data "nutanix_protection_policies_v2" "pp-limit" {
limit = 4
}


// get protection policy by ext id
data "nutanix_protection_policy_v2" "pp-ex1" {
ext_id = nutanix_protection_policy_v2.pp_liner.id
}
5 changes: 5 additions & 0 deletions examples/protection_policy_v2/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#define values to the variables to be used in terraform file
nutanix_username = "admin"
nutanix_password = "password"
nutanix_endpoint = "10.xx.xx.xx"
nutanix_port = 9440
13 changes: 13 additions & 0 deletions examples/protection_policy_v2/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#define the type of variables to be used in terraform file
variable "nutanix_username" {
type = string
}
variable "nutanix_password" {
type = string
}
variable "nutanix_endpoint" {
type = string
}
variable "nutanix_port" {
type = string
}

0 comments on commit ada2101

Please sign in to comment.