Skip to content

Commit 9eeb6fb

Browse files
committed
update per comments
1 parent 9413fe9 commit 9eeb6fb

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

internal/services/dataprotection/data_protection_backup_instance_data_lake_storage_resource.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type BackupInstanceDataLakeStorageModel struct {
2929
Name string `tfschema:"name"`
3030
DataProtectionBackupVaultId string `tfschema:"data_protection_backup_vault_id"`
3131
Location string `tfschema:"location"`
32-
BackupPolicyId string `tfschema:"backup_policy_id"`
32+
BackupPolicyId string `tfschema:"backup_policy_data_lake_storage_id"`
3333
StorageAccountId string `tfschema:"storage_account_id"`
3434
StorageContainerNames []string `tfschema:"storage_container_names"`
3535
ProtectionState string `tfschema:"protection_state"`
@@ -73,14 +73,15 @@ func (r DataProtectionBackupInstanceDataLakeStorageResource) Arguments() map[str
7373

7474
"location": commonschema.Location(),
7575

76-
"backup_policy_id": commonschema.ResourceIDReferenceRequired(&basebackuppolicyresources.BackupPolicyId{}),
76+
"backup_policy_data_lake_storage_id": commonschema.ResourceIDReferenceRequired(&basebackuppolicyresources.BackupPolicyId{}),
7777

7878
"storage_account_id": commonschema.ResourceIDReferenceRequiredForceNew(&commonids.StorageAccountId{}),
7979

8080
"storage_container_names": {
81-
Type: pluginsdk.TypeList,
81+
Type: pluginsdk.TypeSet,
8282
Required: true,
8383
MinItems: 1,
84+
MaxItems: 100,
8485
Elem: &pluginsdk.Schema{
8586
Type: pluginsdk.TypeString,
8687
ValidateFunc: validation.All(
@@ -180,6 +181,8 @@ func (r DataProtectionBackupInstanceDataLakeStorageResource) Create() sdk.Resour
180181
return fmt.Errorf("creating %s: %+v", id, err)
181182
}
182183

184+
// the built-in poller is for the LRO to be finished, but the service requires additional time to finish the configure for backup
185+
// Tracked on https://github.com/Azure/azure-rest-api-specs/issues/41986
183186
pollerType := custompollers.NewDataProtectionBackupInstancePoller(client, id, backupinstanceresources.CurrentProtectionStateProtectionConfigured, []backupinstanceresources.CurrentProtectionState{
184187
backupinstanceresources.CurrentProtectionStateConfiguringProtection,
185188
})
@@ -289,12 +292,10 @@ func (r DataProtectionBackupInstanceDataLakeStorageResource) Update() sdk.Resour
289292

290293
parameters := *existing.Model
291294
if parameters.Properties == nil {
292-
parameters.Properties = &backupinstanceresources.BackupInstance{
293-
PolicyInfo: backupinstanceresources.PolicyInfo{},
294-
}
295+
return fmt.Errorf("retrieving %s: `properties` was nil", id)
295296
}
296297

297-
if metadata.ResourceData.HasChange("backup_policy_id") {
298+
if metadata.ResourceData.HasChange("backup_policy_data_lake_storage_id") {
298299
policyId, err := basebackuppolicyresources.ParseBackupPolicyID(model.BackupPolicyId)
299300
if err != nil {
300301
return err
@@ -303,11 +304,12 @@ func (r DataProtectionBackupInstanceDataLakeStorageResource) Update() sdk.Resour
303304
}
304305

305306
if metadata.ResourceData.HasChange("storage_container_names") {
306-
parameters.Properties.PolicyInfo.PolicyParameters = &backupinstanceresources.PolicyParameters{
307-
BackupDatasourceParametersList: &[]backupinstanceresources.BackupDatasourceParameters{
308-
backupinstanceresources.AdlsBlobBackupDatasourceParameters{
309-
ContainersList: model.StorageContainerNames,
310-
},
307+
if parameters.Properties.PolicyInfo.PolicyParameters == nil {
308+
parameters.Properties.PolicyInfo.PolicyParameters = &backupinstanceresources.PolicyParameters{}
309+
}
310+
parameters.Properties.PolicyInfo.PolicyParameters.BackupDatasourceParametersList = &[]backupinstanceresources.BackupDatasourceParameters{
311+
backupinstanceresources.AdlsBlobBackupDatasourceParameters{
312+
ContainersList: model.StorageContainerNames,
311313
},
312314
}
313315
}
@@ -316,6 +318,8 @@ func (r DataProtectionBackupInstanceDataLakeStorageResource) Update() sdk.Resour
316318
return fmt.Errorf("updating %s: %+v", id, err)
317319
}
318320

321+
// the built-in poller is for the LRO to be finished, but the service requires additional time to finish the configure for backup
322+
// Tracked on https://github.com/Azure/azure-rest-api-specs/issues/41986
319323
pollerType := custompollers.NewDataProtectionBackupInstancePoller(client, *id, backupinstanceresources.CurrentProtectionStateProtectionConfigured, []backupinstanceresources.CurrentProtectionState{
320324
backupinstanceresources.CurrentProtectionStateUpdatingProtection,
321325
})

internal/services/dataprotection/data_protection_backup_instance_data_lake_storage_resource_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ resource "azurerm_storage_account" "test" {
118118
}
119119
120120
resource "azurerm_storage_container" "test" {
121-
name = "testaccsc%[3]d"
121+
name = "acctestsc%[3]d"
122122
storage_account_id = azurerm_storage_account.test.id
123123
}
124124
@@ -155,7 +155,7 @@ func (r DataProtectionBackupInstanceDataLakeStorageResource) templateComplete(da
155155
%s
156156
157157
resource "azurerm_storage_container" "another" {
158-
name = "testaccsc2%[2]d"
158+
name = "acctestsc2%[2]d"
159159
storage_account_id = azurerm_storage_account.test.id
160160
}
161161
@@ -201,7 +201,7 @@ resource "azurerm_data_protection_backup_instance_data_lake_storage" "test" {
201201
data_protection_backup_vault_id = azurerm_data_protection_backup_vault.test.id
202202
location = azurerm_resource_group.test.location
203203
storage_account_id = azurerm_storage_account.test.id
204-
backup_policy_id = azurerm_data_protection_backup_policy_data_lake_storage.test.id
204+
backup_policy_data_lake_storage_id = azurerm_data_protection_backup_policy_data_lake_storage.test.id
205205
storage_container_names = [azurerm_storage_container.test.name]
206206
207207
depends_on = [azurerm_role_assignment.test]
@@ -218,7 +218,7 @@ resource "azurerm_data_protection_backup_instance_data_lake_storage" "import" {
218218
data_protection_backup_vault_id = azurerm_data_protection_backup_instance_data_lake_storage.test.data_protection_backup_vault_id
219219
location = azurerm_data_protection_backup_instance_data_lake_storage.test.location
220220
storage_account_id = azurerm_data_protection_backup_instance_data_lake_storage.test.storage_account_id
221-
backup_policy_id = azurerm_data_protection_backup_instance_data_lake_storage.test.backup_policy_id
221+
backup_policy_data_lake_storage_id = azurerm_data_protection_backup_instance_data_lake_storage.test.backup_policy_data_lake_storage_id
222222
storage_container_names = azurerm_data_protection_backup_instance_data_lake_storage.test.storage_container_names
223223
224224
depends_on = [azurerm_role_assignment.test]
@@ -235,7 +235,7 @@ resource "azurerm_data_protection_backup_instance_data_lake_storage" "test" {
235235
data_protection_backup_vault_id = azurerm_data_protection_backup_vault.test.id
236236
location = azurerm_resource_group.test.location
237237
storage_account_id = azurerm_storage_account.test.id
238-
backup_policy_id = azurerm_data_protection_backup_policy_data_lake_storage.another.id
238+
backup_policy_data_lake_storage_id = azurerm_data_protection_backup_policy_data_lake_storage.another.id
239239
storage_container_names = [azurerm_storage_container.test.name, azurerm_storage_container.another.name]
240240
241241
depends_on = [azurerm_role_assignment.test]
@@ -252,7 +252,7 @@ resource "azurerm_data_protection_backup_instance_data_lake_storage" "test" {
252252
data_protection_backup_vault_id = azurerm_data_protection_backup_vault.test.id
253253
location = azurerm_resource_group.test.location
254254
storage_account_id = azurerm_storage_account.test.id
255-
backup_policy_id = azurerm_data_protection_backup_policy_data_lake_storage.another.id
255+
backup_policy_data_lake_storage_id = azurerm_data_protection_backup_policy_data_lake_storage.another.id
256256
storage_container_names = [azurerm_storage_container.test.name, azurerm_storage_container.another.name]
257257
258258
depends_on = [azurerm_role_assignment.test]

website/docs/r/data_protection_backup_instance_data_lake_storage.html.markdown

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ resource "azurerm_data_protection_backup_instance_data_lake_storage" "example" {
6767
data_protection_backup_vault_id = azurerm_data_protection_backup_vault.example.id
6868
location = azurerm_resource_group.example.location
6969
storage_account_id = azurerm_storage_account.example.id
70-
backup_policy_id = azurerm_data_protection_backup_policy_data_lake_storage.example.id
70+
backup_policy_data_lake_storage_id = azurerm_data_protection_backup_policy_data_lake_storage.example.id
7171
storage_container_names = [azurerm_storage_container.example.name, azurerm_storage_container.example2.name]
7272
7373
depends_on = [azurerm_role_assignment.example]
@@ -78,17 +78,17 @@ resource "azurerm_data_protection_backup_instance_data_lake_storage" "example" {
7878

7979
The following arguments are supported:
8080

81-
* `name` - (Required) The name which should be used for this Backup Instance Data Lake Storage. Changing this forces a new Data Protection Backup instance of Backup Instance Data Lake Storage to be created.
81+
* `name` - (Required) The name which should be used for this Backup Instance Data Lake Storage. Changing this forces a new resource to be created.
8282

83-
* `data_protection_backup_vault_id` - (Required) The ID of the Backup Vault within which the Backup Instance Data Lake Storage should exist. Changing this forces a new Data Protection Backup instance of Backup Instance Data Lake Storage to be created.
83+
* `data_protection_backup_vault_id` - (Required) The ID of the Backup Vault within which the Backup Instance Data Lake Storage should exist. Changing this forces a new resource to be created.
8484

85-
* `location` - (Required) The location of the source Storage Account. Changing this forces a new Data Protection Backup instance of Backup Instance Data Lake Storage to be created.
85+
* `location` - (Required) The location of the source Storage Account. Changing this forces a new resource to be created.
8686

87-
* `backup_policy_id` - (Required) The ID of the Backup Policy.
87+
* `backup_policy_data_lake_storage_id` - (Required) The ID of the Backup Policy.
8888

89-
* `storage_account_id` - (Required) The ID of the source Storage Account. The Storage Account must have Hierarchical Namespace enabled. Changing this forces a new Data Protection Backup instance of Backup Instance Data Lake Storage to be created.
89+
* `storage_account_id` - (Required) The ID of the source Storage Account. The Storage Account must have Hierarchical Namespace enabled. Changing this forces a new resource to be created.
9090

91-
* `storage_container_names` - (Required) The list of the storage container names of the source Storage Account.
91+
* `storage_container_names` - (Required) The names of the storage containers of the source Storage Account.
9292

9393
## Attributes Reference
9494

0 commit comments

Comments
 (0)