Skip to content

Commit 0e0a2c8

Browse files
authored
Fix a bug in the cloud native archival location resources (#202)
Terraform fails to refresh the resources due to an extra level of structure the response from RSC.
1 parent d2f3482 commit 0e0a2c8

6 files changed

+12
-24
lines changed

docs/resources/data_center_archival_location_amazon_s3.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ resource "polaris_data_center_archival_location_amazon_s3" "archival_location" {
7575
- `immutability_settings` (Block List, Max: 1) Enables immutable storage with a time-based retention lock using the AWS immutability feature for your archival location. Once enabled, you cannot delete the snapshots in this archival location before the specified immutability lock period expires. Requires an encryption password policy. (see [below for nested schema](#nestedblock--immutability_settings))
7676
- `kms_master_key` (String) AWS KMS master key ID. Cannot be used with immutable archival locations.
7777
- `retrieval_tier` (String) AWS bucket retrieval tier. Determines the speed and cost of retrieving data from the Glacier and Glacier Flexible Retrieval storage classes. Possible values are `BULK_TIER`, `EXPEDITED_TIER` and `STANDARD_TIER`. Default value is `STANDARD_TIER`.
78-
- `rsa_key` (String, Sensitive) RSA key. Cannot be used with immutable archival locations.
78+
- `rsa_key` (String, Sensitive) PEM encoded private RSA key. Cannot be used with immutable archival locations.
7979
- `storage_class` (String) AWS bucket storage class. Possible values are `STANDARD`, `STANDARD_IA` and `ONEZONE_IA`. Default value is `STANDARD`.
8080

8181
### Read-Only

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
99
github.com/hashicorp/terraform-plugin-docs v0.16.0
1010
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
11-
github.com/rubrikinc/rubrik-polaris-sdk-for-go v0.11.0-beta.4
11+
github.com/rubrikinc/rubrik-polaris-sdk-for-go v0.11.0-beta.5
1212
)
1313

1414
require (

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSg
270270
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
271271
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
272272
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
273-
github.com/rubrikinc/rubrik-polaris-sdk-for-go v0.11.0-beta.4 h1:qhGvTcLjt/FVoxixjRzwDzceeMYwRO8KEXsZuZrwhEI=
274-
github.com/rubrikinc/rubrik-polaris-sdk-for-go v0.11.0-beta.4/go.mod h1:ryJGDKlbaCvozY3Wvt+TPSN2OZRChQedHUNsnVfCbXE=
273+
github.com/rubrikinc/rubrik-polaris-sdk-for-go v0.11.0-beta.5 h1:MlF2JQh/z4QfQ1mcsiQrQwWBEvPP0PC6KCMtRPHSgbA=
274+
github.com/rubrikinc/rubrik-polaris-sdk-for-go v0.11.0-beta.5/go.mod h1:ryJGDKlbaCvozY3Wvt+TPSN2OZRChQedHUNsnVfCbXE=
275275
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
276276
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
277277
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=

internal/provider/resource_aws_archival_location.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func awsCreateArchivalLocation(ctx context.Context, d *schema.ResourceData, m in
161161
Name: d.Get(keyName).(string),
162162
BucketPrefix: d.Get(keyBucketPrefix).(string),
163163
StorageClass: d.Get(keyStorageClass).(string),
164-
Region: aws.ParseRegionNoValidation(d.Get(keyRegion).(string)),
164+
Region: aws.RegionFromName(d.Get(keyRegion).(string)).ToRegionEnum(),
165165
KmsMasterKey: d.Get(keyKMSMasterKey).(string),
166166
BucketTags: toAWSBucketTags(d.Get(keyBucketTags).(map[string]any)),
167167
})
@@ -202,7 +202,7 @@ func awsReadArchivalLocation(ctx context.Context, d *schema.ResourceData, m inte
202202
if err := d.Set(keyBucketPrefix, strings.TrimPrefix(targetTemplate.BucketPrefix, implicitPrefix)); err != nil {
203203
return diag.FromErr(err)
204204
}
205-
if err := d.Set(keyConnectionStatus, targetMapping.ConnectionStatus); err != nil {
205+
if err := d.Set(keyConnectionStatus, targetMapping.ConnectionStatus.Status); err != nil {
206206
return diag.FromErr(err)
207207
}
208208
if err := d.Set(keyKMSMasterKey, targetTemplate.KMSMasterKey); err != nil {
@@ -214,7 +214,7 @@ func awsReadArchivalLocation(ctx context.Context, d *schema.ResourceData, m inte
214214
if err := d.Set(keyName, targetMapping.Name); err != nil {
215215
return diag.FromErr(err)
216216
}
217-
if err := d.Set(keyRegion, targetTemplate.Region); err != nil {
217+
if err := d.Set(keyRegion, targetTemplate.Region.Name()); err != nil {
218218
return diag.FromErr(err)
219219
}
220220
if err := d.Set(keyStorageClass, targetTemplate.StorageClass); err != nil {

internal/provider/resource_azure_archival_location.go

+2-14
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func azureCreateArchivalLocation(ctx context.Context, d *schema.ResourceData, m
180180
Redundancy: d.Get(keyRedundancy).(string),
181181
StorageTier: d.Get(keyStorageTier).(string),
182182
StorageAccountName: d.Get(keyStorageAccountNamePrefix).(string),
183-
StorageAccountRegion: toAzureStorageAccountRegion(d.Get(keyStorageAccountRegion).(string)),
183+
StorageAccountRegion: azure.RegionFromName(d.Get(keyStorageAccountRegion).(string)).ToRegionEnum(),
184184
StorageAccountTags: storageAccountTags,
185185
CMKInfo: toAzureCustomerManagedKeys(d.Get(keyCustomerManagedKey).(*schema.Set)),
186186
})
@@ -219,7 +219,7 @@ func azureReadArchivalLocation(ctx context.Context, d *schema.ResourceData, m in
219219

220220
targetTemplate := targetMapping.TargetTemplate
221221
cloudNativeCompanion := targetTemplate.CloudNativeCompanion
222-
if err := d.Set(keyConnectionStatus, targetMapping.ConnectionStatus); err != nil {
222+
if err := d.Set(keyConnectionStatus, targetMapping.ConnectionStatus.Status); err != nil {
223223
return diag.FromErr(err)
224224
}
225225
if err := d.Set(keyContainerName, targetTemplate.ContainerNamePrefix); err != nil {
@@ -381,15 +381,3 @@ func fromAzureStorageAccountTags(storageAccountTags []azure.Tag) map[string]any
381381

382382
return tags
383383
}
384-
385-
// toAzureStorageAccountRegion converts from the storage account region field
386-
// type to the Azure region enum type. If no region is specified, nil is
387-
// returned.
388-
func toAzureStorageAccountRegion(region string) *azure.RegionEnum {
389-
if storageAccountRegion := azure.RegionFromName(region); storageAccountRegion != azure.RegionUnknown {
390-
regionEnum := storageAccountRegion.ToRegionEnum()
391-
return &regionEnum
392-
}
393-
394-
return nil
395-
}

internal/provider/resource_data_center_archival_location_amazon_s3.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ func resourceDataCenterArchivalLocationAmazonS3() *schema.Resource {
317317
Optional: true,
318318
Sensitive: true,
319319
ExactlyOneOf: []string{keyEncryptionPassword, keyKMSMasterKey},
320-
Description: "RSA key. Cannot be used with immutable archival locations.",
320+
Description: "PEM encoded private RSA key. Cannot be used with immutable archival locations.",
321321
ValidateFunc: validation.StringIsNotWhiteSpace,
322322
},
323323
keyStorageClass: {
@@ -367,7 +367,7 @@ func dataCenterCreateArchivalLocationAmazonS3(ctx context.Context, d *schema.Res
367367
ClusterID: clusterID,
368368
CloudAccountID: cloudAccountID,
369369
BucketName: d.Get(keyBucketName).(string),
370-
Region: aws.ParseRegionNoValidation(d.Get(keyRegion).(string)),
370+
Region: aws.RegionFromName(d.Get(keyRegion).(string)).ToRegionEnum(),
371371
StorageClass: d.Get(keyStorageClass).(string),
372372
RetrievalTier: d.Get(keyRetrievalTier).(string),
373373
KMSMasterKeyID: d.Get(keyKMSMasterKey).(string),
@@ -429,7 +429,7 @@ func dataCenterReadArchivalLocationAmazonS3(ctx context.Context, d *schema.Resou
429429
if err := d.Set(keyBucketName, target.Bucket); err != nil {
430430
return diag.FromErr(err)
431431
}
432-
if err := d.Set(keyRegion, aws.FormatRegion(target.Region)); err != nil {
432+
if err := d.Set(keyRegion, target.Region.Name()); err != nil {
433433
return diag.FromErr(err)
434434
}
435435
if err := d.Set(keyStorageClass, target.StorageClass); err != nil {

0 commit comments

Comments
 (0)