| --- |
| # ---------------------------------------------------------------------------- |
| # |
| # *** AUTO GENERATED CODE *** Type: MMv1 *** |
| # |
| # ---------------------------------------------------------------------------- |
| # |
| # This file is automatically generated by Magic Modules and manual |
| # changes will be clobbered when the file is regenerated. |
| # |
| # Please read more about how to change this file in |
| # .github/CONTRIBUTING.md. |
| # |
| # ---------------------------------------------------------------------------- |
| subcategory: "Google Cloud NetApp Volumes" |
| description: |- |
| Volume replication creates an asynchronous mirror of a volume in a different location. |
| --- |
| |
| # google_netapp_volume_replication |
| |
| Volume replication creates an asynchronous mirror of a volume in a different location. This capability |
| lets you use the replicated volume for critical application activity in case of a location-wide outage |
| or disaster. |
| |
| A new destination volume is created as part of the replication resource. It's content is updated on a |
| schedule with content of the source volume. It can be used as a read-only copy while the mirror is |
| enabled, or as an independent read-write volume while the mirror is stopped. A destination volume will |
| also contain the snapshots of the source volume. Resuming a mirror will overwrite all changes on the |
| destination volume with the content of the source volume. While is mirror is enabled, all configuration |
| changes done to source or destination volumes are automatically done to both. Please note that the |
| destination volume is not a resource managed by Terraform. |
| |
| Reversing the replication direction is not supported through the provider. |
| |
| |
| To get more information about VolumeReplication, see: |
| |
| * [API documentation](https://cloud.google.com/netapp/volumes/docs/reference/rest/v1/projects.locations.volumes.replications) |
| * How-to Guides |
| * [Documentation](https://cloud.google.com/netapp/volumes/docs/protect-data/about-volume-replication) |
| |
| <div class = "oics-button" style="float: right; margin: 0 0 -15px"> |
| <a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=netapp_volume_replication_create&open_in_editor=main.tf" target="_blank"> |
| <img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;"> |
| </a> |
| </div> |
| ## Example Usage - Netapp Volume Replication Create |
| |
| |
| ```hcl |
| |
| data "google_compute_network" "default" { |
| name = "test-network" |
| } |
| |
| resource "google_netapp_storage_pool" "source_pool" { |
| name = "source-pool" |
| location = "us-central1" |
| service_level = "PREMIUM" |
| capacity_gib = 2048 |
| network = data.google_compute_network.default.id |
| } |
| |
| resource "google_netapp_storage_pool" "destination_pool" { |
| name = "destination-pool" |
| location = "us-west2" |
| service_level = "PREMIUM" |
| capacity_gib = 2048 |
| network = data.google_compute_network.default.id |
| } |
| |
| resource "google_netapp_volume" "source_volume" { |
| location = google_netapp_storage_pool.source_pool.location |
| name = "source-volume" |
| capacity_gib = 100 |
| share_name = "source-volume" |
| storage_pool = google_netapp_storage_pool.source_pool.name |
| protocols = [ |
| "NFSV3" |
| ] |
| deletion_policy = "FORCE" |
| } |
| |
| resource "google_netapp_volume_replication" "test_replication" { |
| depends_on = [google_netapp_volume.source_volume] |
| location = google_netapp_volume.source_volume.location |
| volume_name = google_netapp_volume.source_volume.name |
| name = "test-replication" |
| replication_schedule = "EVERY_10_MINUTES" |
| description = "This is a replication resource" |
| destination_volume_parameters { |
| storage_pool = google_netapp_storage_pool.destination_pool.id |
| volume_id = "destination-volume" |
| # Keeping the share_name of source and destination the same |
| # simplifies implementing client failover concepts |
| share_name = "source-volume" |
| description = "This is a replicated volume" |
| } |
| # WARNING: Setting delete_destination_volume to true, will delete the |
| # CURRENT destination volume if the replication is deleted. Omit the field |
| # or set delete_destination_volume=false to avoid accidental volume deletion. |
| delete_destination_volume = true |
| wait_for_mirror = true |
| } |
| ``` |
| |
| ## Argument Reference |
| |
| The following arguments are supported: |
| |
| |
| * `replication_schedule` - |
| (Required) |
| Specifies the replication interval. |
| Possible values are: `EVERY_10_MINUTES`, `HOURLY`, `DAILY`. |
| |
| * `location` - |
| (Required) |
| Name of region for this resource. The resource needs to be created in the region of the destination volume. |
| |
| * `volume_name` - |
| (Required) |
| The name of the existing source volume. |
| |
| * `name` - |
| (Required) |
| The name of the replication. Needs to be unique per location. |
| |
| |
| - - - |
| |
| |
| * `labels` - |
| (Optional) |
| Labels as key value pairs. Example: `{ "owner": "Bob", "department": "finance", "purpose": "testing" }` |
| |
| **Note**: This field is non-authoritative, and will only manage the labels present in your configuration. |
| Please refer to the field `effective_labels` for all of the labels present on the resource. |
| |
| * `destination_volume_parameters` - |
| (Optional) |
| Destination volume parameters. |
| Structure is [documented below](#nested_destination_volume_parameters). |
| |
| * `description` - |
| (Optional) |
| An description of this resource. |
| |
| * `project` - (Optional) The ID of the project in which the resource belongs. |
| If it is not provided, the provider project is used. |
| |
| * `delete_destination_volume` - (Optional) A destination volume is created as part of replication creation. The destination volume will not became |
| under Terraform management unless you import it manually. If you delete the replication, this volume |
| will remain. |
| Setting this parameter to true will delete the *current* destination volume when destroying the |
| replication. If you reversed the replication direction, this will be your former source volume! |
| For production use, it is recommended to keep this parameter false to avoid accidental volume |
| deletion. Handle with care. Default is false. |
| |
| * `replication_enabled` - (Optional) Set to false to stop/break the mirror. Stopping the mirror makes the destination volume read-write |
| and act independently from the source volume. |
| Set to true to enable/resume the mirror. WARNING: Resuming a mirror overwrites any changes |
| done to the destination volume with the content of the source volume. |
| |
| * `force_stopping` - (Optional) Only replications with mirror_state=MIRRORED can be stopped. A replication in mirror_state=TRANSFERRING |
| currently receives an update and stopping the update might be undesirable. Set this parameter to true |
| to stop anyway. All data transferred to the destination will be discarded and content of destination |
| volume will remain at the state of the last successful update. Default is false. |
| |
| * `wait_for_mirror` - (Optional) Replication resource state is independent of mirror_state. With enough data, it can take many hours |
| for mirror_state to reach MIRRORED. If you want Terraform to wait for the mirror to finish on |
| create/stop/resume operations, set this parameter to true. Default is false. |
| |
| |
| <a name="nested_destination_volume_parameters"></a>The `destination_volume_parameters` block supports: |
| |
| * `storage_pool` - |
| (Required) |
| Name of an existing storage pool for the destination volume with format: `projects/{{project}}/locations/{{location}}/storagePools/{{poolId}}` |
| |
| * `volume_id` - |
| (Optional) |
| Name for the destination volume to be created. If not specified, the name of the source volume will be used. |
| |
| * `share_name` - |
| (Optional) |
| Share name for destination volume. If not specified, name of source volume's share name will be used. |
| |
| * `description` - |
| (Optional) |
| Description for the destination volume. |
| |
| ## Attributes Reference |
| |
| In addition to the arguments listed above, the following computed attributes are exported: |
| |
| * `id` - an identifier for the resource with format `projects/{{project}}/locations/{{location}}/volumes/{{volume_name}}/replications/{{name}}` |
| |
| * `state` - |
| Indicates the state of replication resource. State of the mirror itself is indicated in mirrorState. |
| |
| * `state_details` - |
| State details of the replication resource. |
| |
| * `role` - |
| Reverting a replication can swap source and destination volume roles. This field indicates if the `location` hosts |
| the source or destination volume. For resume and revert and resume operations it is critical to understand |
| which volume is the source volume, since it will overwrite changes done to the destination volume. |
| |
| * `mirror_state` - |
| Indicates the state of the mirror between source and destination volumes. Depending on the amount of data |
| in your source volume, PREPARING phase can take hours or days. mirrorState = MIRRORED indicates your baseline |
| transfer ended and destination volume became accessible read-only. TRANSFERRING means a MIRRORED volume |
| currently receives an update. Updated every 5 minutes. |
| |
| * `create_time` - |
| Create time of the active directory. A timestamp in RFC3339 UTC "Zulu" format. Examples: "2023-06-22T09:13:01.617Z". |
| |
| * `destination_volume` - |
| Full resource name of destination volume with format: `projects/{{project}}/locations/{{location}}/volumes/{{volumeId}}` |
| |
| * `transfer_stats` - |
| Replication transfer statistics. All statistics are updated every 5 minutes. |
| Structure is [documented below](#nested_transfer_stats). |
| |
| * `source_volume` - |
| Full resource name of source volume with format: `projects/{{project}}/locations/{{location}}/volumes/{{volumeId}}` |
| |
| * `healthy` - |
| Condition of the relationship. Can be one of the following: |
| - true: The replication relationship is healthy. It has not missed the most recent scheduled transfer. |
| - false: The replication relationship is not healthy. It has missed the most recent scheduled transfer. |
| |
| * `terraform_labels` - |
| The combination of labels configured directly on the resource |
| and default labels configured on the provider. |
| |
| * `effective_labels` - |
| All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services. |
| |
| |
| <a name="nested_transfer_stats"></a>The `transfer_stats` block contains: |
| |
| * `transfer_bytes` - |
| (Output) |
| Cumulative bytes transferred so far for the replication relationship. |
| |
| * `total_transfer_duration` - |
| (Output) |
| Cumulative time taken across all transfers for the replication relationship. |
| |
| * `last_transfer_bytes` - |
| (Output) |
| Size of last completed transfer in bytes. |
| |
| * `last_transfer_duration` - |
| (Output) |
| Time taken during last completed transfer. |
| |
| * `lag_duration` - |
| (Output) |
| The elapsed time since the creation of the snapshot on the source volume that was last replicated |
| to the destination volume. Lag time represents the difference in age of the destination volume |
| data in relation to the source volume data. |
| |
| * `update_time` - |
| (Output) |
| Time when progress was updated last. A timestamp in RFC3339 UTC "Zulu" format. Examples: "2023-06-22T09:13:01.617Z". |
| |
| * `last_transfer_end_time` - |
| (Output) |
| Time when last transfer completed. A timestamp in RFC3339 UTC "Zulu" format. Examples: "2023-06-22T09:13:01.617Z". |
| |
| * `last_transfer_error` - |
| (Output) |
| A message describing the cause of the last transfer failure. |
| |
| ## Timeouts |
| |
| This resource provides the following |
| [Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: |
| |
| - `create` - Default is 20 minutes. |
| - `update` - Default is 20 minutes. |
| - `delete` - Default is 20 minutes. |
| |
| ## Import |
| |
| |
| VolumeReplication can be imported using any of these accepted formats: |
| |
| * `projects/{{project}}/locations/{{location}}/volumes/{{volume_name}}/replications/{{name}}` |
| * `{{project}}/{{location}}/{{volume_name}}/{{name}}` |
| * `{{location}}/{{volume_name}}/{{name}}` |
| |
| |
| In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import VolumeReplication using one of the formats above. For example: |
| |
| ```tf |
| import { |
| id = "projects/{{project}}/locations/{{location}}/volumes/{{volume_name}}/replications/{{name}}" |
| to = google_netapp_volume_replication.default |
| } |
| ``` |
| |
| When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), VolumeReplication can be imported using one of the formats above. For example: |
| |
| ``` |
| $ terraform import google_netapp_volume_replication.default projects/{{project}}/locations/{{location}}/volumes/{{volume_name}}/replications/{{name}} |
| $ terraform import google_netapp_volume_replication.default {{project}}/{{location}}/{{volume_name}}/{{name}} |
| $ terraform import google_netapp_volume_replication.default {{location}}/{{volume_name}}/{{name}} |
| ``` |
| |
| ## User Project Overrides |
| |
| This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override). |