Skip to content

Commit

Permalink
PLT-1443: Added backup storage location for other available storage t…
Browse files Browse the repository at this point in the history
…ypes. (#546)

* initial commit

* PLT-1443:Added Backup storage for other providers(Minio, gcp and azure).

* added validation on back up storage location

* disable unit test

* incorporated review comments
  • Loading branch information
SivaanandM authored Nov 19, 2024
1 parent 4264c78 commit adbe025
Show file tree
Hide file tree
Showing 8 changed files with 1,196 additions and 199 deletions.
37 changes: 32 additions & 5 deletions docs/resources/backup_storage_location.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,49 @@ resource "spectrocloud_backup_storage_location" "bsl2" {

### Required

- `bucket_name` (String) The name of the storage bucket where backups are stored. This is relevant for S3 or S3-compatible storage services.
- `is_default` (Boolean) Specifies if this backup storage location should be used as the default location for storing backups.
- `name` (String) The name of the backup storage location. This is a unique identifier for the backup location.
- `region` (String) The region where the backup storage is located, typically corresponding to the region of the cloud provider.
- `s3` (Block List, Min: 1, Max: 1) S3-specific settings for configuring the backup storage location. (see [below for nested schema](#nestedblock--s3))

### Optional

- `ca_cert` (String) An optional CA certificate used for SSL connections to ensure secure communication with the storage provider.
- `azure_storage_config` (Block List, Max: 1) Azure storage settings for configuring the backup storage location. (see [below for nested schema](#nestedblock--azure_storage_config))
- `bucket_name` (String) The name of the storage bucket where backups are stored. This is relevant for S3 or S3-compatible(minio) or gcp storage services.
- `ca_cert` (String) An optional CA certificate used for SSL connections to ensure secure communication with the storage provider. This is relevant for S3 or S3-compatible(minio) storage services.
- `context` (String) The context of the backup storage location. Allowed values are `project` or `tenant`. Default value is `project`. If the `project` context is specified, the project name will sourced from the provider configuration parameter [`project_name`](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs#schema).
- `gcp_storage_config` (Block List, Max: 1) GCP storage settings for configuring the backup storage location. (see [below for nested schema](#nestedblock--gcp_storage_config))
- `is_default` (Boolean) Specifies if this backup storage location should be used as the default location for storing backups.
- `region` (String) The region where the backup storage is located, typically corresponding to the region of the cloud provider. This is relevant for S3 or S3-compatible(minio) storage services.
- `s3` (Block List, Max: 1) S3-specific settings for configuring the backup storage location. (see [below for nested schema](#nestedblock--s3))
- `storage_provider` (String) The location provider for backup storage location. Allowed values are `aws` or `minio` or `gcp` or `azure`. Default value is `aws`.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

### Read-Only

- `id` (String) The ID of this resource.

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

Required:

- `azure_client_id` (String) Unique client Id from Azure console.
- `azure_client_secret` (String, Sensitive) Azure secret for authentication.
- `azure_tenant_id` (String) Unique tenant Id from Azure console.
- `container_name` (String) The container name.
- `resource_group` (String) The resource group name.
- `stock_keeping_unit` (String) The stop-keeping unit. eg: `Standard_LRS`
- `storage_name` (String) The storage name.
- `subscription_id` (String) Unique subscription Id from Azure console.


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

Required:

- `gcp_json_credentials` (String, Sensitive) The GCP credentials in JSON format. These credentials are required to authenticate and manage.
- `project_id` (String) The GCP project ID.


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

Expand Down
95 changes: 73 additions & 22 deletions examples/resources/spectrocloud_backup_storage_location/resource.tf
Original file line number Diff line number Diff line change
@@ -1,29 +1,80 @@
resource "spectrocloud_backup_storage_location" "bsl1" {
name = "aaa-project-dev-1"
context = "project"
is_default = false
region = "us-east-1"
bucket_name = "project-backup-2"
// S3 Backup location with secret credential type example
resource "spectrocloud_backup_storage_location" "bsl_s3" {
name = "project-dev-bsl-s3"
context = "project"
location_provider = "aws"
is_default = false
region = "us-east-1"
bucket_name = "project-backup-bucket-s3"
s3 {
credential_type = "secret"
access_key = "access_key"
secret_key = "secret_key"
access_key = "test-access-key-s3"
secret_key = "test-secret-key-s3"
s3_force_path_style = false
s3_url = "https://s3.us-east-1.amazonaws.com"
}
}

// Minio Backup location with secret credential type example
resource "spectrocloud_backup_storage_location" "bsl_minio" {
name = "project-dev-minio-bsl"
context = "project"
location_provider = "minio"
is_default = false
region = "us-east-2"
bucket_name = "project-backup-bucket-minio"
s3 {
credential_type = "secret"
access_key = "test-access-key-minio"
secret_key = "test-secret-key-minio"
s3_force_path_style = true
s3_url = "http://10.90.78.23"
}
}

#resource "spectrocloud_backup_storage_location" "bsl2" {
# name = "tenant-dev-1"
# context = "tenant"
# is_default = false
# region = "us-east-2"
# bucket_name = "tenant-backup-2"
# s3 {
# credential_type = "sts"
# arn = "arn_role"
# external_id = "external_id"
# s3_force_path_style = false
# #s3_url = "http://10.90.78.23"
# }
#}
// GCP Backup location example
resource "spectrocloud_backup_storage_location" "bsl_gcp" {
name = "project-dev-gcp"
context = "project"
location_provider = "gcp"
is_default = false
bucket_name = "project-backup-bucket-gcp"
gcp_storage_config {
project_id = "test-gcp-project-id"
gcp_json_credentials = ""
}
}

// Azure Backup location example
resource "spectrocloud_backup_storage_location" "bsl_azure" {
name = "project-dev-azure-bsl"
context = "project"
location_provider = "azure"
is_default = false
azure_storage_config {
container_name = "test-container"
storage_name = "test-storage"
stock_keeping_unit = "Standard_LRS"
resource_group = "test-resource-group"
azure_tenant_id = "test-azure-tenant-id"
azure_client_id = "test-azure-client-id"
subscription_id = "test-azure-subscription-id"
azure_client_secret = ""
}
}

// S3 Backup location with STS credential type
resource "spectrocloud_backup_storage_location" "bsl_sts" {
name = "tenant-dev-1"
context = "tenant"
is_default = false
region = "us-east-2"
bucket_name = "tenant-backup-bucket-sts"
s3 {
credential_type = "sts"
arn = "arn:aws:role/TestRole"
external_id = "test-external-id"
s3_force_path_style = false
s3_url = "https://s3.us-east-2.amazonaws.com"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ variable "sc_project_name" {
default = "Default"
}

variable "credential_type" {}

variable "aws_access_key" {}
variable "aws_secret_key" {}

variable "arn" {}
variable "external_id" {}
#variable "credential_type" {
#default = "secret"
#}
#
#variable "aws_access_key" {}
#variable "aws_secret_key" {}
#
#variable "arn" {}
#variable "external_id" {}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/robfig/cron v1.2.0
github.com/spectrocloud/gomi v1.14.1-0.20240214074114-c19394812368
github.com/spectrocloud/hapi v1.14.1-0.20240214071352-81f589b1d86d
github.com/spectrocloud/palette-sdk-go v0.0.0-20241118165324-009eeef47438
github.com/spectrocloud/palette-sdk-go v0.0.0-20241119041221-487ede67d589
github.com/stretchr/testify v1.9.0
gotest.tools v2.2.0+incompatible
k8s.io/api v0.23.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ github.com/spectrocloud/gomi v1.14.1-0.20240214074114-c19394812368 h1:eY0BOyEbGu
github.com/spectrocloud/gomi v1.14.1-0.20240214074114-c19394812368/go.mod h1:LlZ9We4kDaELYi7Is0SVmnySuDhwphJLS6ZT4wXxFIk=
github.com/spectrocloud/hapi v1.14.1-0.20240214071352-81f589b1d86d h1:OMRbHxMJ1a+G1BYzvUYuMM0wLkYJPdnEOFx16faQ/UY=
github.com/spectrocloud/hapi v1.14.1-0.20240214071352-81f589b1d86d/go.mod h1:MktpRPnSXDTHsQrFSD+daJFQ1zMLSR+1gWOL31jVvWE=
github.com/spectrocloud/palette-sdk-go v0.0.0-20241118165324-009eeef47438 h1:TboPvQjtapjSclbQ9aviF9mrnrS0Xz9xLYfKxF/gdRY=
github.com/spectrocloud/palette-sdk-go v0.0.0-20241118165324-009eeef47438/go.mod h1:dSlNvDS0qwUWTbrYI6P8x981mcbbRHFrBg67v5zl81U=
github.com/spectrocloud/palette-sdk-go v0.0.0-20241119041221-487ede67d589 h1:2Z+GDgDu/f5vtQTNx2UNNRda5Vbr3i7F/RE+e8pNfrs=
github.com/spectrocloud/palette-sdk-go v0.0.0-20241119041221-487ede67d589/go.mod h1:dSlNvDS0qwUWTbrYI6P8x981mcbbRHFrBg67v5zl81U=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
Expand Down
Loading

0 comments on commit adbe025

Please sign in to comment.