Skip to content

Commit

Permalink
Merge pull request #73 from arangodb-managed/OAS-5111
Browse files Browse the repository at this point in the history
OAS-5111 | add resources for oasis multi region backup
  • Loading branch information
adoi authored Sep 27, 2022
2 parents f8b4ae3 + 3dd8f54 commit 68303a9
Show file tree
Hide file tree
Showing 22 changed files with 557 additions and 64 deletions.
4 changes: 0 additions & 4 deletions docs/guides/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ resource "oasis_deployment" "my_oneshard_deployment" {
region = "gcp-europe-west4"
}
version {
db_version = "3.8.6"
}
configuration {
model = "oneshard"
}
Expand Down
5 changes: 2 additions & 3 deletions docs/resources/backup.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ resource "oasis_deployment" "my_oneshard_deployment" {
location {
region = "gcp-europe-west4"
}
version {
db_version = "3.8.6"
}
configuration {
model = "oneshard"
node_size_id = "c4-a8"
Expand Down Expand Up @@ -87,6 +85,7 @@ resource "oasis_backup" "my_backup" {
### Read-Only

- `id` (String) The ID of this resource.
- `region_id` (String) Oasis Backup Resource Region Identifier
- `url` (String) Oasis Backup Resource Backup URL field


1 change: 1 addition & 0 deletions docs/resources/backup_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ resource "oasis_backup_policy" "my_backup_policy" {

### Optional

- `additional_region_ids` (List of String) Backup Policy Resource Additional Region Identifiers where backup should be cloned
- `description` (String) Backup Policy Resource Backup Policy Description field
- `is_paused` (Boolean) Backup Policy Resource Backup Policy Is Paused field
- `locked` (Boolean) Backup Policy Resource Backup Policy Locked field
Expand Down
4 changes: 0 additions & 4 deletions docs/resources/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ resource "oasis_deployment" "my_oneshard_deployment" {
region = "gcp-europe-west4"
}
version {
db_version = "3.8.6"
}
configuration {
model = "oneshard"
}
Expand Down
98 changes: 98 additions & 0 deletions docs/resources/multi_region_backup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "oasis_multi_region_backup Resource - terraform-provider-oasis"
subcategory: ""
description: |-
Oasis Multi Region Backup Resource
---

# oasis_multi_region_backup (Resource)

Oasis Multi Region Backup Resource

## Example Usage

```terraform
terraform {
required_version = ">= 0.13.0"
required_providers {
oasis = {
source = "arangodb-managed/oasis"
version = ">=2.1.5"
}
}
}
provider "oasis" {
api_key_id = "" // API Key ID generated in Oasis platform
api_key_secret = "" // API Key Secret generated in Oasis platform
organization = "" // Your Oasis organization where you want to create the resources
}
// Create Project
resource "oasis_project" "oasis_test_project" {
name = "Terraform Oasis Project"
description = "A test Oasis project within an organization from the Terraform Provider"
}
// Create Deployment
resource "oasis_deployment" "my_oneshard_deployment" {
terms_and_conditions_accepted = "true"
project = oasis_project.oasis_test_project.id // Project id where deployment will be created
name = "oasis_multi_region_deployment"
location {
region = "gcp-europe-west4"
}
security {
disable_foxx_authentication = false
}
disk_performance = "dp30"
configuration {
model = "oneshard"
node_size_id = "c4-a8"
node_disk_size = 20
maximum_node_disk_size = 40
}
notification_settings {
email_addresses = [
"[email protected]"
]
}
}
// Create Backup
resource "oasis_backup" "backup" {
name = "oasis_backup"
description = "test backup description update from terraform"
deployment_id = oasis_deployment.my_oneshard_deployment.id
upload = true
auto_deleted_at = 3 // auto delete after 3 days
}
// Create Multi Region Backup
resource "oasis_multi_region_backup" "backup" {
source_backup_id = oasis_backup.backup.id // Existing backup ID
region_id = "gcp-us-central1" // Oasis region identifier, which is other than the deployment region
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `region_id` (String) Oasis Multi Region Backup Resource Region Identifier
- `source_backup_id` (String) Oasis Multi Region Backup Resource Region Identifier

### Read-Only

- `auto_deleted_at` (Number) Oasis Multi Region Backup Resource Backup Auto Delete At field, generated based on source backup
- `backup_policy_id` (String) Oasis Multi Region Backup Resource Backup Policy ID field, generated based on source backup
- `deployment_id` (String) Oasis Multi Region Backup Resource Backup Deployment ID field, generated based on source backup
- `description` (String) Oasis Multi Region Backup Resource Backup Description field, generated based on source backup
- `id` (String) The ID of this resource.
- `name` (String) Oasis Multi Region Backup Resource Backup Name field, generated based on source backup
- `upload` (Boolean) Oasis Multi Region Backup Resource Backup Upload field, generated based on source backup
- `url` (String) Oasis Multi Region Backup Resource Backup URL field, generated based on source backup


18 changes: 10 additions & 8 deletions docs/resources/private_endpoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ resource "oasis_deployment" "my_aks_oneshard_deployment" {
region = "aks-westus2"
}
version {
db_version = "3.8.6"
}
configuration {
model = "oneshard"
}
Expand Down Expand Up @@ -81,10 +77,6 @@ resource "oasis_deployment" "my_aws_oneshard_deployment" {
region = "aws-us-east-2"
}
version {
db_version = "3.8.6"
}
configuration {
model = "oneshard"
}
Expand Down Expand Up @@ -126,6 +118,7 @@ resource "oasis_private_endpoint" "my_aws_private_endpoint" {
- `aws` (Block List, Max: 1) Private Endpoint Resource Private Endpoint AWS field (see [below for nested schema](#nestedblock--aws))
- `description` (String) Private Endpoint Resource Private Endpoint Description field
- `dns_names` (List of String) Private Endpoint Resource Private Endpoint DNS Names field (list of dns names)
- `gcp` (Block List, Max: 1) Private Endpoint Resource Private Endpoint GCP field (see [below for nested schema](#nestedblock--gcp))

### Read-Only

Expand Down Expand Up @@ -159,3 +152,12 @@ Optional:
- `user_names` (List of String) Private Endpoint Resource Private Endpoint AWS Principal User Names field



<a id="nestedblock--gcp"></a>
### Nested Schema for `gcp`

Required:

- `projects` (List of String) Private Endpoint Resource Private Endpoint GCP Projects field (list of project ids)


4 changes: 1 addition & 3 deletions examples/resources/oasis_backup/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ resource "oasis_deployment" "my_oneshard_deployment" {
location {
region = "gcp-europe-west4"
}
version {
db_version = "3.8.6"
}

configuration {
model = "oneshard"
node_size_id = "c4-a8"
Expand Down
4 changes: 0 additions & 4 deletions examples/resources/oasis_deployment/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ resource "oasis_deployment" "my_oneshard_deployment" {
region = "gcp-europe-west4"
}

version {
db_version = "3.8.6"
}

configuration {
model = "oneshard"
}
Expand Down
26 changes: 26 additions & 0 deletions examples/resources/oasis_multi_region_backup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Example: Multi Region Backup

This example shows how to use the Terraform Oasis provider to create an Oasis Multi Region backup inside a Deployment.

## Prerequisites

_This example uses syntax elements specific to Terraform version 0.13+ (tested on Terraform version 1.1.4).
It will not work out-of-the-box with Terraform 0.12.x and lower._

## Environment variables

Please refer to [Main README](../../README.md) file for all the environment variables you might need.

## Instructions on how to run:

```
terraform init
terraform plan
terraform apply
```

To remove the resources created run:

```
terraform destroy
```
61 changes: 61 additions & 0 deletions examples/resources/oasis_multi_region_backup/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
terraform {
required_version = ">= 0.13.0"
required_providers {
oasis = {
source = "arangodb-managed/oasis"
version = ">=2.1.6"
}
}
}

provider "oasis" {
api_key_id = "" // API Key ID generated in Oasis platform
api_key_secret = "" // API Key Secret generated in Oasis platform
organization = "" // Your Oasis organization where you want to create the resources
}

// Create Project
resource "oasis_project" "oasis_test_project" {
name = "Terraform Oasis Project"
description = "A test Oasis project within an organization from the Terraform Provider"
}

// Create Deployment
resource "oasis_deployment" "my_oneshard_deployment" {
terms_and_conditions_accepted = "true"
project = oasis_project.oasis_test_project.id // Project id where deployment will be created
name = "oasis_multi_region_deployment"
location {
region = "gcp-europe-west4"
}
security {
disable_foxx_authentication = false
}
disk_performance = "dp30"
configuration {
model = "oneshard"
node_size_id = "c4-a8"
node_disk_size = 20
maximum_node_disk_size = 40
}
notification_settings {
email_addresses = [
"[email protected]"
]
}
}

// Create Backup
resource "oasis_backup" "backup" {
name = "oasis_backup"
description = "test backup description update from terraform"
deployment_id = oasis_deployment.my_oneshard_deployment.id
upload = true
auto_deleted_at = 3 // auto delete after 3 days
}

// Create Multi Region Backup
resource "oasis_multi_region_backup" "backup" {
source_backup_id = oasis_backup.backup.id // Existing backup ID
region_id = "gcp-us-central1" // Oasis region identifier, which is other than the deployment region
}
8 changes: 0 additions & 8 deletions examples/resources/oasis_private_endpoint/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ resource "oasis_deployment" "my_aks_oneshard_deployment" {
region = "aks-westus2"
}

version {
db_version = "3.8.6"
}

configuration {
model = "oneshard"
}
Expand Down Expand Up @@ -66,10 +62,6 @@ resource "oasis_deployment" "my_aws_oneshard_deployment" {
region = "aws-us-east-2"
}

version {
db_version = "3.8.6"
}

configuration {
model = "oneshard"
}
Expand Down
1 change: 1 addition & 0 deletions internal/data_source_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,6 @@ func flattenBackupObject(backup *backup.Backup) map[string]interface{} {
backupDataSourcePolicyIDFieldName: backup.GetBackupPolicyId(),
backupDataSourceDeploymentIDFieldName: backup.GetDeploymentId(),
backupDataSourceCreatedAtFieldName: backup.GetCreatedAt().String(),
backupRegionIDFieldName: backup.GetRegionId(),
}
}
2 changes: 2 additions & 0 deletions internal/data_source_backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestFlattenBackupObject(t *testing.T) {
CreatedAt: createdAtTimeStamp,
BackupPolicyId: "test-policy-id",
DeploymentId: "test-dep-id",
RegionId: "gcp-europe-west4",
}

expected := map[string]interface{}{
Expand All @@ -51,6 +52,7 @@ func TestFlattenBackupObject(t *testing.T) {
backupDataSourceCreatedAtFieldName: "2022-01-01T01:01:01Z",
backupDataSourceDeploymentIDFieldName: "test-dep-id",
backupDataSourcePolicyIDFieldName: "test-policy-id",
backupRegionIDFieldName: "gcp-europe-west4",
}

got := flattenBackupObject(&backup)
Expand Down
1 change: 1 addition & 0 deletions internal/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func Provider() *schema.Provider {
"oasis_ipallowlist": resourceIPAllowlist(),
"oasis_certificate": resourceCertificate(),
"oasis_backup": resourceBackup(),
"oasis_multi_region_backup": resourceMultiRegionBackup(),
"oasis_backup_policy": resourceBackupPolicy(),
"oasis_project": resourceProject(),
"oasis_example_dataset_installation": resourceExampleDatasetInstallation(),
Expand Down
7 changes: 7 additions & 0 deletions internal/resource_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ func resourceBackup() *schema.Resource {
Description: "Oasis Backup Resource Backup Policy ID field",
Optional: true,
},
backupRegionIDFieldName: {
Type: schema.TypeString,
Description: "Oasis Backup Resource Region Identifier",
Computed: true,
ForceNew: true,
},
backupAutoDeleteAtFieldName: {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -258,5 +264,6 @@ func flattenBackupResource(backup *backup.Backup) map[string]interface{} {
backupURLFieldName: backup.GetUrl(),
backupPolicyIDFieldName: backup.GetBackupPolicyId(),
backupDeploymentIDFieldName: backup.GetDeploymentId(),
backupRegionIDFieldName: backup.GetRegionId(),
}
}
Loading

0 comments on commit 68303a9

Please sign in to comment.