Skip to content

Commit

Permalink
add depends_on
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-henglu committed Aug 30, 2021
1 parent 9095ecc commit cfdd281
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,20 @@ func (r DataProtectionBackupInstanceBlobStorageResource) template(data acceptanc
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctest-dataprotection-%d"
location = "%s"
}
resource "azurerm_storage_account" "test" {
name = "acctestsa%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_data_protection_backup_vault" "test" {
name = "acctest-dataprotection-vault-%d"
resource_group_name = azurerm_resource_group.test.name
Expand All @@ -127,16 +130,19 @@ resource "azurerm_data_protection_backup_vault" "test" {
type = "SystemAssigned"
}
}
resource "azurerm_role_assignment" "test" {
scope = azurerm_storage_account.test.id
role_definition_name = "Storage Account Backup Contributor Role"
principal_id = azurerm_data_protection_backup_vault.test.identity[0].principal_id
}
resource "azurerm_data_protection_backup_policy_blob_storage" "test" {
name = "acctest-dbp-%d"
vault_id = azurerm_data_protection_backup_vault.test.id
retention_duration = "P30D"
}
resource "azurerm_data_protection_backup_policy_blob_storage" "another" {
name = "acctest-dbp-other-%d"
vault_id = azurerm_data_protection_backup_vault.test.id
Expand All @@ -155,6 +161,8 @@ resource "azurerm_data_protection_backup_instance_blob_storage" "test" {
vault_id = azurerm_data_protection_backup_vault.test.id
storage_account_id = azurerm_storage_account.test.id
backup_policy_id = azurerm_data_protection_backup_policy_blob_storage.test.id
depends_on = [azurerm_role_assignment.test]
}
`, template, data.RandomInteger)
}
Expand All @@ -169,6 +177,8 @@ resource "azurerm_data_protection_backup_instance_blob_storage" "import" {
vault_id = azurerm_data_protection_backup_instance_blob_storage.test.vault_id
storage_account_id = azurerm_data_protection_backup_instance_blob_storage.test.storage_account_id
backup_policy_id = azurerm_data_protection_backup_instance_blob_storage.test.backup_policy_id
depends_on = [azurerm_role_assignment.test]
}
`, config)
}
Expand All @@ -183,6 +193,8 @@ resource "azurerm_data_protection_backup_instance_blob_storage" "test" {
vault_id = azurerm_data_protection_backup_vault.test.id
storage_account_id = azurerm_storage_account.test.id
backup_policy_id = azurerm_data_protection_backup_policy_blob_storage.another.id
depends_on = [azurerm_role_assignment.test]
}
`, template, data.RandomInteger)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,44 @@ resource "azurerm_resource_group" "rg" {
name = "example-resources"
location = "West Europe"
}
resource "azurerm_storage_account" "example" {
name = "example-storage-account"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "LRS"
}
resource "azurerm_data_protection_backup_vault" "example" {
name = "example-backup-vault"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
datastore_type = "VaultStore"
redundancy = "LocallyRedundant"
}
resource "azurerm_role_assignment" "example" {
scope = azurerm_storage_account.example.id
role_definition_name = "Storage Account Backup Contributor Role"
principal_id = azurerm_data_protection_backup_vault.example.identity[0].principal_id
}
resource "azurerm_data_protection_backup_policy_blob_storage" "example" {
name = "example-backup-policy"
resource_group_name = azurerm_resource_group.rg.name
vault_name = azurerm_data_protection_backup_vault.example.name
retention_duration = "P30D"
}
resource "azurerm_data_protection_backup_instance_blob_storage" "example" {
name = "example-backup-instance"
vault_id = azurerm_data_protection_backup_vault.example.id
storage_account_location = azurerm_resource_group.rg.location
storage_account_id = azurerm_storage_account.example.id
backup_policy_id = azurerm_data_protection_backup_policy_blob_storage.example.id
depends_on = [azurerm_role_assignment.example]
}
```

Expand Down

0 comments on commit cfdd281

Please sign in to comment.