Skip to content

Commit

Permalink
docs and examples for get protected resource datasource
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroon-Dweikat-Ntx committed Jan 21, 2025
1 parent 7749c1e commit eedcab6
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 0 deletions.
72 changes: 72 additions & 0 deletions examples/protected_resource_v2/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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
}

resource "nutanix_protection_policy_v2" "pp_1"{
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>"]
}

resource "nutanix_virtual_machine_v2" "vm" {
name = "%[2]s"
description = "%[3]s"
num_cores_per_socket = 1
num_sockets = 1
cluster {
ext_id = data.nutanix_clusters_v2.clusters.cluster_entities.0.ext_id
}
categories {
ext_id = local.category1
}
power_state = "OFF"
depends_on = [nutanix_protection_policy_v2.test]
}

data "nutanix_protected_resource_v2" "pr" {
ext_id = nutanix_virtual_machine_v2.vm.id
}
5 changes: 5 additions & 0 deletions examples/protected_resource_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/protected_resource_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
}
90 changes: 90 additions & 0 deletions website/docs/d/protected_resource_v2.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
layout: "nutanix"
page_title: "NUTANIX: protected_resource_v2"
sidebar_current: "docs-nutanix-datasource-protected-resource-v2"
description: |-
Get a protected resource
---

# protected_resource_v2

Get the details of the specified protected resource such as the restorable time ranges available on the local Prism Central and the state of replication to the targets specified in the applied protection policies. This applies only if the entity is protected in a minutely or synchronous schedule. Other protection schedules are not served by this endpoint yet, and are considered not protected.


## Example

```hcl
resource "nutanix_protection_policy_v2" "pp_1"{
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>"]
}
resource "nutanix_virtual_machine_v2" "vm"{
name = "%[2]s"
description = "%[3]s"
num_cores_per_socket = 1
num_sockets = 1
cluster {
ext_id = data.nutanix_clusters_v2.clusters.cluster_entities.0.ext_id
}
categories {
ext_id = local.category1
}
power_state = "OFF"
depends_on = [nutanix_protection_policy_v2.test]
}
data "nutanix_protected_resource_v2" "pr"{
ext_id = nutanix_virtual_machine_v2.vm.id
}
```

## Argument Reference

The following arguments are supported:

* `ext_id`: -(Required) The external identifier of a protected VM or volume group that can be used to retrieve the protected resource.


## Attributes Reference
The following attributes are exported:



See detailed information in [Nutanix Get Protected Resource v4](https://developers.nutanix.com/api-reference?namespace=dataprotection&version=v4.0#tag/ProtectedResources/operation/getProtectedResourceById).

0 comments on commit eedcab6

Please sign in to comment.