Skip to content

Commit

Permalink
Add support for Azure archival locations (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
johan3141592 committed May 27, 2024
1 parent db58084 commit c6e12c9
Show file tree
Hide file tree
Showing 9 changed files with 457 additions and 18 deletions.
4 changes: 1 addition & 3 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ page_title: "Changelog"
# Changelog

## v0.9.0-beta.4
* Fix an issue with the permissions of subscriptions onboarded using the `polaris_azure_subscription` resource where
the RSC UI would show the status as "Update permissions" even though the app registration would have all the required
permissions.
* Add support for creating Azure cloud native archival locations. [[docs](resources/azure_archival_location)]

## v0.9.0-beta.3
* Fix a bug in the `polaris_aws_exocompute` resource where customer supplied security groups were not validated
Expand Down
59 changes: 59 additions & 0 deletions docs/resources/azure_archival_location.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "polaris_azure_archival_location Resource - terraform-provider-polaris"
subcategory: ""
description: |-
The polaris_azure_archival_location resource creates an RSC archival location for cloud-native workloads.
When creating an archival location, the region where the snapshots are stored needs to be specified:
* Source Region - Store snapshots in the same region to minimize data transfer charges. This is the default behaviour when the storage_account_region field is not specified.
* Specific region - Storing snapshots in another region can increase total data transfer charges. The storage_account_region field specifies the region.
Custom storage encryption is enabled by specifying one or more customer_managed_key blocks. Each customer_managed_key block specifies the encryption details to use for a region. For other regions, data will be encrypted using platform managed keys.
-> Note: The Azure storage account is not created until the first protected object is archived to the location.
---

# polaris_azure_archival_location (Resource)

The `polaris_azure_archival_location` resource creates an RSC archival location for cloud-native workloads.

When creating an archival location, the region where the snapshots are stored needs to be specified:
* *Source Region* - Store snapshots in the same region to minimize data transfer charges. This is the default behaviour when the `storage_account_region` field is not specified.
* *Specific region* - Storing snapshots in another region can increase total data transfer charges. The `storage_account_region` field specifies the region.

Custom storage encryption is enabled by specifying one or more `customer_managed_key` blocks. Each `customer_managed_key` block specifies the encryption details to use for a region. For other regions, data will be encrypted using platform managed keys.

-> **Note:** The Azure storage account is not created until the first protected object is archived to the location.



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

### Required

- `cloud_account_id` (String) RSC cloud account ID.
- `name` (String) Cloud native archival location name.
- `storage_account_name_prefix` (String) Azure storage account name prefix. The storage account name prefix cannot be longer than 14 characters and can only consist of numbers and lower case letters.

### Optional

- `customer_managed_key` (Block Set) Customer managed storage encryption. Specify the regions and their respective encryption details. For other regions, data will be encrypted using platform managed keys. (see [below for nested schema](#nestedblock--customer_managed_key))
- `redundancy` (String) Azure storage redundancy. Possible values are `GRS`, `GZRS`, `LRS`, `RA_GRS`, `RA_GZRS` and `ZRS`. Default value is `LRS`.
- `storage_account_region` (String) Azure region to store the snapshots in. If not specified, the snapshots will be stored in the same region as the workload.
- `storage_account_tags` (Map of String) Azure storage account tags. Each tag will be added to the storage account created by RSC.
- `storage_tier` (String) Azure storage tier. Possible values are `COOL` and `HOT`. Default value is `COOL`.

### Read-Only

- `connection_status` (String) Connection status of the cloud native archival location.
- `container_name` (String) Azure storage container name.
- `id` (String) Cloud native archival location ID.
- `location_template` (String) RSC location template. If a storage account region was specified, it will be `SPECIFIC_REGION`, otherwise `SOURCE_REGION`.

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

Required:

- `name` (String) Key name.
- `region` (String) The region in which the key will be used. Regions without customer managed keys will use platform managed keys.
- `vault_name` (String) Key vault name.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.0
github.com/rubrikinc/rubrik-polaris-sdk-for-go v0.10.0-beta.5
github.com/rubrikinc/rubrik-polaris-sdk-for-go v0.10.0-beta.6
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rubrikinc/rubrik-polaris-sdk-for-go v0.10.0-beta.5 h1:J/+s4lkvAn9FHb8gYY14Ea6wsCSNMS/Dhz+hs+R4YOw=
github.com/rubrikinc/rubrik-polaris-sdk-for-go v0.10.0-beta.5/go.mod h1:670TFQkxTdbsBwEwR/fDT75hfHwPDTTOiLnyZerbqQk=
github.com/rubrikinc/rubrik-polaris-sdk-for-go v0.10.0-beta.6 h1:zGFHwJHotDDXgdN7WzQWTh8BDjCzGWTsrMJ1/3Ro+wg=
github.com/rubrikinc/rubrik-polaris-sdk-for-go v0.10.0-beta.6/go.mod h1:670TFQkxTdbsBwEwR/fDT75hfHwPDTTOiLnyZerbqQk=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=
Expand Down
1 change: 1 addition & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func Provider() *schema.Provider {
"polaris_aws_exocompute": resourceAwsExocompute(),
"polaris_aws_exocompute_cluster_attachment": resourceAwsExocomputeClusterAttachment(),
"polaris_aws_private_container_registry": resourceAwsPrivateContainerRegistry(),
keyPolarisAzureArchivalLocation: resourceAzureArchivalLocation(),
keyPolarisAzureExocompute: resourceAzureExocompute(),
keyPolarisAzureServicePrincipal: resourceAzureServicePrincipal(),
keyPolarisAzureSubscription: resourceAzureSubscription(),
Expand Down
9 changes: 4 additions & 5 deletions internal/provider/resource_aws_archival_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ func awsUpdateArchivalLocation(ctx context.Context, d *schema.ResourceData, m in
// Lookup and parse the target mapping ID from the resource ID.
targetMappingID, err := uuid.Parse(d.Id())
if err != nil {
d.SetId("")
return diag.FromErr(err)
}

Expand Down Expand Up @@ -255,8 +254,8 @@ func awsDeleteArchivalLocation(ctx context.Context, d *schema.ResourceData, m in
return nil
}

// fromBucketTags converts from the bucket tags argument to a standard string to
// string map.
// fromBucketTags converts from the bucket tags argument to a standard
// string-to-string map.
func fromBucketTags(bucketTags map[string]any) (map[string]string, error) {
tags := make(map[string]string, len(bucketTags))
for key, value := range bucketTags {
Expand All @@ -270,8 +269,8 @@ func fromBucketTags(bucketTags map[string]any) (map[string]string, error) {
return tags, nil
}

// toBucketTags converts to the bucket tags argument from a standard string to
// string map.
// toBucketTags converts to the bucket tags argument from a standard
// string-to-string map.
func toBucketTags(tags map[string]string) map[string]any {
bucketTags := make(map[string]any, len(tags))
for key, value := range tags {
Expand Down
Loading

0 comments on commit c6e12c9

Please sign in to comment.