-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add backuppolicy resource and data sources (#54)
This change adds the backuppolicy resource for managing backup policies via the NuoDB DBaaS REST API, the backuppolicy data source for obtaining the state of an existing backup policy, and the backuppolicies data source for listing existing backup policies. Other changes: - Update the set of REST resources and models that we generate Golang code for using oapi-codegen, which exposed a bug in oapi-codegen (oapi-codegen/oapi-codegen#1614). The fix-generated.sh script implements a workaround for that bug. - Strip ANSI color codes and remove special formatting and line-wrapping from Error and Warning messages to allow asserts to check for the presence of substrings. - Change the examples tests to only run `terraform validate` on the examples, rather than `terraform plan` or `terraform apply`. This allows us to test the examples without a server, which avoids introducing dependencies on the REST server supporting a particular resource or data source.
- Loading branch information
1 parent
90702f5
commit 8841acc
Showing
30 changed files
with
8,378 additions
and
2,460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "nuodbaas_backuppolicies Data Source - nuodbaas" | ||
subcategory: "" | ||
description: |- | ||
Data source for listing NuoDB backup policies created using the DBaaS Control Plane | ||
--- | ||
|
||
# nuodbaas_backuppolicies (Data Source) | ||
|
||
Data source for listing NuoDB backup policies created using the DBaaS Control Plane | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
# Data source that returns the fully-qualified names of all backup policies | ||
data "nuodbaas_backuppolicies" "policy_list" {} | ||
# Data source that returns the fully-qualified names of backup policies within an organization | ||
data "nuodbaas_backuppolicies" "org_policy_list" { | ||
filter = { | ||
organization = "org" | ||
} | ||
} | ||
# Data source that returns the fully-qualified names of backup policies satisfying label requirements | ||
data "nuodbaas_backuppolicies" "label_policy_list" { | ||
filter = { | ||
labels = ["withkey", "key=expected", "key!=unexpected", "!withoutkey"] | ||
} | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- `filter` (Attributes) Filters to apply to policies (see [below for nested schema](#nestedatt--filter)) | ||
|
||
### Read-Only | ||
|
||
- `policies` (Attributes List) The list of policies that satisfy the filter requirements (see [below for nested schema](#nestedatt--policies)) | ||
|
||
<a id="nestedatt--filter"></a> | ||
### Nested Schema for `filter` | ||
|
||
Optional: | ||
|
||
- `labels` (List of String) List of filters to apply based on labels, which are composed using `AND`. Acceptable filter expressions are: | ||
* `key` - Only return items that have label with specified key | ||
* `key=value` - Only return items that have label with specified key set to value | ||
* `!key` - Only return items that do _not_ have label with specified key | ||
* `key!=value` - Only return items that do _not_ have label with specified key set to value | ||
- `organization` (String) The organization to filter policies on | ||
|
||
|
||
<a id="nestedatt--policies"></a> | ||
### Nested Schema for `policies` | ||
|
||
Read-Only: | ||
|
||
- `name` (String) The name of the policy | ||
- `organization` (String) The organization the policy belongs to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "nuodbaas_backuppolicy Data Source - nuodbaas" | ||
subcategory: "" | ||
description: |- | ||
Data source for exposing information about NuoDB backup policies created using the DBaaS Control Plane | ||
--- | ||
|
||
# nuodbaas_backuppolicy (Data Source) | ||
|
||
Data source for exposing information about NuoDB backup policies created using the DBaaS Control Plane | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
# Data source that returns the attributes of a specific backup policy | ||
data "nuodbaas_backuppolicy" "policy_details" { | ||
organization = "org" | ||
name = "pol" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) The name of the backup policy | ||
- `organization` (String) The organization that the backup policy belongs to | ||
|
||
### Read-Only | ||
|
||
- `frequency` (String) The frequency to schedule backups at, in cron format | ||
- `labels` (Map of String) User-defined labels attached to the resource that can be used for filtering | ||
- `properties` (Attributes) (see [below for nested schema](#nestedatt--properties)) | ||
- `retention` (Attributes) (see [below for nested schema](#nestedatt--retention)) | ||
- `selector` (Attributes) (see [below for nested schema](#nestedatt--selector)) | ||
- `status` (Attributes) (see [below for nested schema](#nestedatt--status)) | ||
- `suspended` (Boolean) Whether backups from the policy are suspended | ||
|
||
<a id="nestedatt--properties"></a> | ||
### Nested Schema for `properties` | ||
|
||
Read-Only: | ||
|
||
- `propagate_database_labels` (Boolean) Whether to propagate the user-defined labels from the matching database to backup resources created by this policy | ||
- `propagate_policy_labels` (Boolean) Whether to propagate the user-defined labels from the backup policy to backup resources created by this policy | ||
|
||
|
||
<a id="nestedatt--retention"></a> | ||
### Nested Schema for `retention` | ||
|
||
Read-Only: | ||
|
||
- `daily` (Number) The number of daily backups to retain | ||
- `hourly` (Number) The number of hourly backups to retain | ||
- `monthly` (Number) The number of monthly backups to retain | ||
- `weekly` (Number) The number of weekly backups to retain | ||
- `yearly` (Number) The number of yearly backups to retain | ||
|
||
|
||
<a id="nestedatt--selector"></a> | ||
### Nested Schema for `selector` | ||
|
||
Read-Only: | ||
|
||
- `labels` (Map of String) The user-defined labels to filter databases on | ||
- `scope` (String) The scope that the backup policy applies to | ||
- `slas` (List of String) The SLAs to filter databases on | ||
- `tiers` (List of String) The tiers to filter databases on | ||
|
||
|
||
<a id="nestedatt--status"></a> | ||
### Nested Schema for `status` | ||
|
||
Read-Only: | ||
|
||
- `last_missed_schedule_time` (String) The time that backups were last missed by this policy | ||
- `last_schedule_time` (String) The time that backups were last taken by this policy | ||
- `next_schedule_time` (String) The time that backups are next scheduled by this policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "nuodbaas_backuppolicy Resource - nuodbaas" | ||
subcategory: "" | ||
description: |- | ||
Resource for managing NuoDB backup policies created using the DBaaS Control Plane | ||
--- | ||
|
||
# nuodbaas_backuppolicy (Resource) | ||
|
||
Resource for managing NuoDB backup policies created using the DBaaS Control Plane | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
# A backup policy with minimal configuration | ||
resource "nuodbaas_backuppolicy" "basic" { | ||
organization = "org" | ||
name = "basic" | ||
frequency = "@weekly" | ||
selector = { | ||
scope = "org" | ||
} | ||
} | ||
# A backup policy with explicit configuration for various attributes | ||
resource "nuodbaas_backuppolicy" "pol" { | ||
organization = "org" | ||
name = "pol" | ||
labels = { | ||
"provisioned-by" : "terraform" | ||
} | ||
frequency = "@daily" | ||
selector = { | ||
scope = "org" | ||
slas = ["qa", "prod"] | ||
tiers = ["n0.small", "n1.small"] | ||
labels = { | ||
"rpo" : "1d" | ||
} | ||
} | ||
retention = { | ||
hourly = 24 | ||
daily = 7 | ||
weekly = 4 | ||
monthly = 12 | ||
yearly = 3 | ||
} | ||
suspended = false | ||
properties = { | ||
propagate_policy_labels = true | ||
propagate_database_labels = true | ||
} | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `frequency` (String) The frequency to schedule backups at, in cron format | ||
- `name` (String) The name of the backup policy | ||
- `organization` (String) The organization that the backup policy belongs to | ||
- `selector` (Attributes) (see [below for nested schema](#nestedatt--selector)) | ||
|
||
### Optional | ||
|
||
- `labels` (Map of String) User-defined labels attached to the resource that can be used for filtering | ||
- `properties` (Attributes) (see [below for nested schema](#nestedatt--properties)) | ||
- `retention` (Attributes) (see [below for nested schema](#nestedatt--retention)) | ||
- `suspended` (Boolean) Whether backups from the policy are suspended | ||
|
||
### Read-Only | ||
|
||
- `status` (Attributes) (see [below for nested schema](#nestedatt--status)) | ||
|
||
<a id="nestedatt--selector"></a> | ||
### Nested Schema for `selector` | ||
|
||
Required: | ||
|
||
- `scope` (String) The scope that the backup policy applies to | ||
|
||
Optional: | ||
|
||
- `labels` (Map of String) The user-defined labels to filter databases on | ||
- `slas` (List of String) The SLAs to filter databases on | ||
- `tiers` (List of String) The tiers to filter databases on | ||
|
||
|
||
<a id="nestedatt--properties"></a> | ||
### Nested Schema for `properties` | ||
|
||
Optional: | ||
|
||
- `propagate_database_labels` (Boolean) Whether to propagate the user-defined labels from the matching database to backup resources created by this policy | ||
- `propagate_policy_labels` (Boolean) Whether to propagate the user-defined labels from the backup policy to backup resources created by this policy | ||
|
||
|
||
<a id="nestedatt--retention"></a> | ||
### Nested Schema for `retention` | ||
|
||
Optional: | ||
|
||
- `daily` (Number) The number of daily backups to retain | ||
- `hourly` (Number) The number of hourly backups to retain | ||
- `monthly` (Number) The number of monthly backups to retain | ||
- `weekly` (Number) The number of weekly backups to retain | ||
- `yearly` (Number) The number of yearly backups to retain | ||
|
||
|
||
<a id="nestedatt--status"></a> | ||
### Nested Schema for `status` | ||
|
||
Read-Only: | ||
|
||
- `last_missed_schedule_time` (String) The time that backups were last missed by this policy | ||
- `last_schedule_time` (String) The time that backups were last taken by this policy | ||
- `next_schedule_time` (String) The time that backups are next scheduled by this policy | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# An existing backup policy can be imported by specifying the organization | ||
# and policy name, separated by "/" | ||
terraform import nuodbaas_backuppolicy.pol org/pol | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
examples/data-sources/nuodbaas_backuppolicies/data-source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Data source that returns the fully-qualified names of all backup policies | ||
data "nuodbaas_backuppolicies" "policy_list" {} | ||
|
||
# Data source that returns the fully-qualified names of backup policies within an organization | ||
data "nuodbaas_backuppolicies" "org_policy_list" { | ||
filter = { | ||
organization = "org" | ||
} | ||
} | ||
|
||
# Data source that returns the fully-qualified names of backup policies satisfying label requirements | ||
data "nuodbaas_backuppolicies" "label_policy_list" { | ||
filter = { | ||
labels = ["withkey", "key=expected", "key!=unexpected", "!withoutkey"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Data source that returns the attributes of a specific backup policy | ||
data "nuodbaas_backuppolicy" "policy_details" { | ||
organization = "org" | ||
name = "pol" | ||
} |
Oops, something went wrong.