Skip to content

Commit

Permalink
feat(cbr): update vault and add a new data_source (#960)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason-Zhang9309 authored Jul 7, 2023
1 parent 94388a8 commit e3a6964
Show file tree
Hide file tree
Showing 8 changed files with 494 additions and 76 deletions.
180 changes: 180 additions & 0 deletions docs/data-sources/cbr_backup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
---
subcategory: "Cloud Backup and Recovery (CBR)"
---

# flexibleengine_cbr_backup

Use this data source to query the backup detail using its ID within FlexibleEngine.

## Example Usage

### Using backup ID to query the backup detail

```hcl
variable "backup_id" {}
data "flexibleengine_cbr_backup" "test" {
id = "backup_id"
}
```

## Argument reference

The following arguments are supported:

* `region` - (Optional, String) Specifies the region in which to query the backup detail.
If omitted, the provider-level region will be used.

* `id` - (Required, String) Specifies the backup ID.

## Attributes Reference

In addition to all arguments above, the following attributes are exported:

* `parent_id` - The parent backup ID.

* `type` - The backup type.

* `name` - The backup name.

* `description` - The backup description.

* `checkpoint_id` - The restore point ID.

* `resource_id` - The backup resource ID.

* `resource_type` - The backup resource type.

* `resource_size` - The backup resource size, in GB.

* `resource_name` - The backup resource name.

* `resource_az` - The availability zone where the backup resource is located.

* `enterprise_project_id` - The enterprise project to which the backup resource belongs.

* `vault_id` - The vault to which the backup resource belongs.

* `replication_records` - The replication records.
The [object](#cbr_backup_replication_records) structure is documented below.

* `children` - The backup list of the sub-backup resources.
The [object](#cbr_backup_children) structure is documented below.

* `extend_info` - The extended information.
The [object](#cbr_backup_extend_info) structure is documented below.

* `status` - The backup status.

* `created_at` - The creation time of the backup.

* `updated_at` - The latest update time of the backup.

* `expired_at` - The expiration time of the backup.

<a name="cbr_backup_replication_records"></a>
The `replication_records` block supports:

* `id` - The replication record ID.

* `destination_backup_id` - The ID of the destination backup used for replication.

* `destination_checkpoint_id` - The record ID of the destination backup used for replication.

* `destination_project_id` - The ID of the replication destination project.

* `destination_region` - The replication destination region.

* `destination_vault_id` - The destination vault ID.

* `source_backup_id` - The ID of the source backup used for replication.

* `source_checkpoint_id` - The ID of the source backup record used for replication.

* `source_project_id` - The ID of the replication source project.

* `source_region` - The replication source region.

* `status` - The replication status.

* `vault_id` - The ID of the vault where the backup resides.

* `extra_info` - The additional information of the replication.
The [object](#cbr_backup_replication_record_extra_info) structure is documented below.

* `created_at` - The creation time of the replication.

<a name="cbr_backup_replication_record_extra_info"></a>
The `extra_info` block supports:

* `progress` - The replication progress.

* `fail_code` - The error code.

* `fail_reason` - The error cause.

* `auto_trigger` - Whether replication is automatically scheduled.

* `destination_vault_id` - The destination vault ID.

<a name="cbr_backup_children"></a>
The `children` block supports:

* `id` - The sub-backup ID.

* `name` - The sub-backup name.

* `description` - The sub-backup description.

* `type` - The sub-backup type.

* `checkpoint_id` - The restore point ID of the sub-backup resource.

* `resource_id` - The sub-backup resource ID.

* `resource_type` - The sub-backup resource type.

* `resource_size` - The sub-backup resource size, in GB.

* `resource_name` - The sub-backup resource name.

* `resource_az` - The availability zone where the backup sub-backup resource is located.

* `enterprise_project_id` - The enterprise project to which the backup sub-backup resource belongs.

* `vault_id` - The vault to which the backup resource belongs.

* `replication_records` - The replication records.

* `extend_info` - The extended information.

* `status` - The sub-backup status.

* `created_at` - The creation time of the sub-backup.

* `updated_at` - The latest update time of the sub-backup.

* `expired_at` - The expiration time of the sub-backup.

<a name="cbr_backup_extend_info"></a>
The `extend_info` block supports:

* `auto_trigger` - Whether the backup is automatically generated.

* `bootable` - Whether the backup is a system disk backup.

* `incremental` - Whether the backup is an incremental backup.

* `snapshot_id` - Snapshot ID of the disk backup.

* `support_lld` - Whether to allow lazyloading for fast restoration.

* `supported_restore_mode` - The restoration mode.

* `os_registry_images` - The ID list of images created using backups.

* `contain_system_disk` - Whether the VM backup data contains system disk data.

* `encrypted` - Whether the backup is encrypted.

* `is_system_disk` - Whether the disk is a system disk.
44 changes: 27 additions & 17 deletions docs/data-sources/cbr_vaults.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,55 +20,62 @@ data "flexibleengine_cbr_vaults" "test" {

The following arguments are supported:

* `region` - (Optional, String) Specifies the region in which to query the CBR vaults.
* `region` - (Optional, String) Specifies the region in which to query the vaults.
If omitted, the provider-level region will be used.

* `name` - (Optional, String) Specifies a unique name of the CBR vault. This parameter can contain a maximum of 64
* `name` - (Optional, String) Specifies the vault name. This parameter can contain a maximum of 64
characters, which may consist of letters, digits, underscores(_) and hyphens (-).

* `type` - (Optional, String) Specifies the object type of the CBR vault. The vaild values are as follows:
* `type` - (Optional, String) Specifies the object type of the vault. The vaild values are as follows:
+ **server** (Cloud Servers)
+ **disk** (EVS Disks)
+ **turbo** (SFS Turbo file systems)

* `protection_type` - (Optional, String) Specifies the protection type of the CBR vault.
* `consistent_level` - (Optional, String) Specifies the consistent level (specification) of the vault.
The valid values are as follows:
+ **[crash_consistent](https://docs.prod-cloud-ocb.orange-business.com/usermanual/cbr/cbr_03_0109.html)**
+ **[app_consistent](https://docs.prod-cloud-ocb.orange-business.com/usermanual/cbr/cbr_03_0109.html)**

Only server type vaults support application consistent.

* `protection_type` - (Optional, String) Specifies the protection type of the vault.
The valid values are **backup** and **replication**. Vaults of type **disk** don't support **replication**.

* `size` - (Optional, Int) Specifies the vault sapacity, in GB. The valid value range is `1` to `10,485,760`.

* `auto_expand_enabled` - (Optional, Bool) Specifies whether to enable automatic expansion of the backup protection
type vault. Default to **false**.
type vault. Defaults to **false**.

* `policy_id` - (Optional, String) Specifies a policy to associate with the CBR vault.
* `policy_id` - (Optional, String) Specifies the ID of the policy associated with the vault.
The `policy_id` cannot be used with the vault of replicate protection type.

* `status` - (Optional, String) Specifies the CBR vault status, including **available**, **lock**, **frozen** and **error**.
* `status` - (Optional, String) Specifies the vault status, including **available**, **lock**, **frozen** and **error**.

## Attributes Reference

In addition to all arguments above, the following attributes are exported:

* `id` - The data source ID in hashcode format.

* `vaults` - List of CBR vault details. The object structure of each CBR vault is documented below.
* `vaults` - List of vault details. The object structure of each vault is documented below.

The `vaults` block supports:

* `id` - The vault ID in UUID format.

* `name` - The CBR vault name.
* `name` - The vault name.

* `type` - The object type of the CBR vault.
* `type` - The object type of the vault.

* `consistent_level` - The backup specifications. The valid value is **crash_consistent**.
* `consistent_level` - The consistent level (specification) of the vault.

* `protection_type` - The protection type of the CBR vault.
* `protection_type` - The protection type of the vault.

* `size` - The vault capacity, in GB.

* `auto_expand_enabled` - Whether to enable automatic expansion of the backup protection type vault.

* `policy_id` - The policy associated with the CBR vault.
* `policy_id` - The ID of the policy associated with the vault.

* `allocated` - The allocated capacity of the vault, in GB.

Expand All @@ -80,13 +87,16 @@ The `vaults` block supports:

* `storage` - The name of the bucket for the vault.

* `tags` - The key/value pairs to associate with the CBR vault.
* `tags` - The key/value pairs to associate with the vault.

* `resources` - An array of one or more resources to attach to the CBR vault.
The object structure is documented below.
* `resources` - The array of one or more resources to attach to the vault.
The [object](#cbr_vault_resources) structure is documented below.

<a name="cbr_vault_resources"></a>
The `resources` block supports:

* `server_id` - The ID of the ECS instance to be backed up.

* `includes` - An array of disk or SFS file system IDs which will be included in the backup.
* `excludes` - The array of disk IDs which will be excluded in the backup.

* `includes` - The array of disk or SFS file system IDs which will be included in the backup.
53 changes: 40 additions & 13 deletions docs/resources/cbr_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ resource "flexibleengine_cbr_policy" "test" {

```hcl
variable "policy_name" {}
variable "dest_region" {}
variable "dest_project_id" {}
variable "destination_region" {}
variable "destination_project_id" {}
resource "flexibleengine_cbr_policy" "test" {
name = var.policy_name
type = "replication"
destination_region = var.dest_region
destination_project_id = var.dest_project_id
destination_region = var.destination_region
destination_project_id = var.destination_project_id
backup_quantity = 20
backup_cycle {
Expand All @@ -54,24 +54,29 @@ resource "flexibleengine_cbr_policy" "test" {

The following arguments are supported:

* `region` - (Optional, String, ForceNew) Specifies the region in which to create the CBR policy. If omitted, the
* `region` - (Optional, String, ForceNew) Specifies the region where the policy is located. If omitted, the
provider-level region will be used. Changing this will create a new policy.

* `name` - (Required, String) Specifies a unique name of the CBR policy. This parameter can contain a maximum of 64
characters, which may consist of chinese charactors, letters, digits, underscores(_) and hyphens (-).
* `name` - (Required, String) Specifies the policy name.
This parameter can contain a maximum of 64
characters, which may consist of chinese characters, letters, digits, underscores(_) and hyphens (-).

* `type` - (Required, String, ForceNew) Specifies the protection type of the CBR policy.
* `type` - (Required, String, ForceNew) Specifies the protection type of the policy.
Valid values are **backup** and **replication**.
Changing this will create a new policy.

* `backup_cycle` - (Required, List) Specifies the scheduling rule for the CBR policy backup execution.
* `backup_cycle` - (Required, List) Specifies the scheduling rule for the policy backup execution.
The [object](#cbr_policy_backup_cycle) structure is documented below.

* `enabled` - (Optional, Bool) Specifies whether to enable the CBR policy. Default to **true**.
* `enabled` - (Optional, Bool) Specifies whether to enable the policy. Default to **true**.

* `destination_region` - (Optional, String) Specifies the name of the replication destination region, which is mandatory
for cross-region replication. Required if `protection_type` is **replication**.

* `enable_acceleration` - (Optional, Bool, ForceNew) Specifies whether to enable the acceleration function to shorten
the replication time for cross-region.
Changing this will create a new policy.

* `destination_project_id` - (Optional, String) Specifies the ID of the replication destination project, which is
mandatory for cross-region replication. Required if `protection_type` is **replication**.

Expand All @@ -90,8 +95,8 @@ The following arguments are supported:
When the number of retained backups exceeds the preset value (number of `backup_quantity`), the system automatically
deletes the earliest backups. By default, the system automatically clears data every other day.

* `time_zone` - (Optional, String) Specifies the UTC time zone, e.g.: `UTC+08:00`.
Required if `long_term_retention` is set.
* `time_zone` - (Optional, String) Specifies the UTC time zone, e.g. `UTC+08:00`.
Only available if `long_term_retention` is set.

<a name="cbr_policy_backup_cycle"></a>
The `backup_cycle` block supports:
Expand Down Expand Up @@ -121,6 +126,10 @@ The `long_term_retention` block supports:
-> A maximum of 10 backups are retained for failed periodic backup tasks. They are retained for one month and can be
manually deleted on the web console.

* `full_backup_interval` - (Optional, Int) Specifies how often (after how many incremental backups) a full backup is
performed. The valid value ranges from `-1` to `100`.
If `-1` is specified, full backup will not be performed.

## Attributes Reference

In addition to all arguments above, the following attributes are exported:
Expand All @@ -131,6 +140,24 @@ In addition to all arguments above, the following attributes are exported:

Policies can be imported by their `id`. For example,

```shell
```bash
terraform import flexibleengine_cbr_policy.test 4d2c2939-774f-42ef-ab15-e5b126b11ace
```

Note that the imported state may not be identical to your resource definition, due to the attribute missing from the
API response. The missing attribute is: `enable_acceleration`.
It is generally recommended running `terraform plan` after importing a policy.
You can then decide if changes should be applied to the policy, or the resource definition should be updated to align
with the policy. Also you can ignore changes as below.

```hcl
resource "flexibleengine_cbr_policy" "test" {
...
lifecycle {
ignore_changes = [
enable_acceleration,
]
}
}
```
Loading

0 comments on commit e3a6964

Please sign in to comment.