BackupInstancePostgresql

class BackupInstancePostgresql : KotlinCustomResource

Manages a Backup Instance to back up PostgreSQL.

Note: Before using this resource, there are some prerequisite permissions for configure backup and restore. See more details from https://docs.microsoft.com/azure/backup/backup-azure-database-postgresql#prerequisite-permissions-for-configure-backup-and-restore.

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.CoreFunctions;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.postgresql.Server;
import com.pulumi.azure.postgresql.ServerArgs;
import com.pulumi.azure.postgresql.FirewallRule;
import com.pulumi.azure.postgresql.FirewallRuleArgs;
import com.pulumi.azure.postgresql.Database;
import com.pulumi.azure.postgresql.DatabaseArgs;
import com.pulumi.azure.dataprotection.BackupVault;
import com.pulumi.azure.dataprotection.BackupVaultArgs;
import com.pulumi.azure.dataprotection.inputs.BackupVaultIdentityArgs;
import com.pulumi.azure.keyvault.KeyVault;
import com.pulumi.azure.keyvault.KeyVaultArgs;
import com.pulumi.azure.keyvault.inputs.KeyVaultAccessPolicyArgs;
import com.pulumi.azure.keyvault.Secret;
import com.pulumi.azure.keyvault.SecretArgs;
import com.pulumi.azure.dataprotection.BackupPolicyPostgresql;
import com.pulumi.azure.dataprotection.BackupPolicyPostgresqlArgs;
import com.pulumi.azure.authorization.Assignment;
import com.pulumi.azure.authorization.AssignmentArgs;
import com.pulumi.azure.dataprotection.BackupInstancePostgresql;
import com.pulumi.azure.dataprotection.BackupInstancePostgresqlArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var current = CoreFunctions.getClientConfig();
var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()
.location("West Europe")
.build());
var exampleServer = new Server("exampleServer", ServerArgs.builder()
.location(exampleResourceGroup.location())
.resourceGroupName(exampleResourceGroup.name())
.skuName("B_Gen5_2")
.storageMb(5120)
.backupRetentionDays(7)
.geoRedundantBackupEnabled(false)
.autoGrowEnabled(true)
.administratorLogin("psqladmin")
.administratorLoginPassword("H@Sh1CoR3!")
.version("9.5")
.sslEnforcementEnabled(true)
.build());
var exampleFirewallRule = new FirewallRule("exampleFirewallRule", FirewallRuleArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.serverName(exampleServer.name())
.startIpAddress("0.0.0.0")
.endIpAddress("0.0.0.0")
.build());
var exampleDatabase = new Database("exampleDatabase", DatabaseArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.serverName(exampleServer.name())
.charset("UTF8")
.collation("English_United States.1252")
.build());
var exampleBackupVault = new BackupVault("exampleBackupVault", BackupVaultArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.location(exampleResourceGroup.location())
.datastoreType("VaultStore")
.redundancy("LocallyRedundant")
.identity(BackupVaultIdentityArgs.builder()
.type("SystemAssigned")
.build())
.build());
var exampleKeyVault = new KeyVault("exampleKeyVault", KeyVaultArgs.builder()
.location(exampleResourceGroup.location())
.resourceGroupName(exampleResourceGroup.name())
.tenantId(current.applyValue(getClientConfigResult -> getClientConfigResult.tenantId()))
.skuName("premium")
.softDeleteRetentionDays(7)
.accessPolicies(
KeyVaultAccessPolicyArgs.builder()
.tenantId(current.applyValue(getClientConfigResult -> getClientConfigResult.tenantId()))
.objectId(current.applyValue(getClientConfigResult -> getClientConfigResult.objectId()))
.keyPermissions(
"Create",
"Get")
.secretPermissions(
"Set",
"Get",
"Delete",
"Purge",
"Recover")
.build(),
KeyVaultAccessPolicyArgs.builder()
.tenantId(exampleBackupVault.identity().applyValue(identity -> identity.tenantId()))
.objectId(exampleBackupVault.identity().applyValue(identity -> identity.principalId()))
.keyPermissions(
"Create",
"Get")
.secretPermissions(
"Set",
"Get",
"Delete",
"Purge",
"Recover")
.build())
.build());
var exampleSecret = new Secret("exampleSecret", SecretArgs.builder()
.value(Output.tuple(exampleServer.name(), exampleDatabase.name(), exampleServer.name()).applyValue(values -> {
var exampleServerName = values.t1;
var exampleDatabaseName = values.t2;
var exampleServerName1 = values.t3;
return String.format("Server=%s.postgres.database.azure.com;Database=%s;Port=5432;User Id=psqladmin@%s;Password=H@Sh1CoR3!;Ssl Mode=Require;", exampleServerName,exampleDatabaseName,exampleServerName1);
}))
.keyVaultId(exampleKeyVault.id())
.build());
var exampleBackupPolicyPostgresql = new BackupPolicyPostgresql("exampleBackupPolicyPostgresql", BackupPolicyPostgresqlArgs.builder()
.resourceGroupName(exampleResourceGroup.name())
.vaultName(exampleBackupVault.name())
.backupRepeatingTimeIntervals("R/2021-05-23T02:30:00+00:00/P1W")
.defaultRetentionDuration("P4M")
.build());
var exampleAssignment = new Assignment("exampleAssignment", AssignmentArgs.builder()
.scope(exampleServer.id())
.roleDefinitionName("Reader")
.principalId(exampleBackupVault.identity().applyValue(identity -> identity.principalId()))
.build());
var exampleBackupInstancePostgresql = new BackupInstancePostgresql("exampleBackupInstancePostgresql", BackupInstancePostgresqlArgs.builder()
.location(exampleResourceGroup.location())
.vaultId(exampleBackupVault.id())
.databaseId(exampleDatabase.id())
.backupPolicyId(exampleBackupPolicyPostgresql.id())
.databaseCredentialKeyVaultSecretId(exampleSecret.versionlessId())
.build());
}
}

Import

Backup Instance PostgreSQL can be imported using the resource id, e.g.

$ pulumi import azure:dataprotection/backupInstancePostgresql:BackupInstancePostgresql example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.DataProtection/backupVaults/vault1/backupInstances/backupInstance1

Properties

Link copied to clipboard
val backupPolicyId: Output<String>

The ID of the Backup Policy.

Link copied to clipboard

The ID or versionless ID of the key vault secret which stores the connection string of the database.

Link copied to clipboard
val databaseId: Output<String>

The ID of the source database. Changing this forces a new Backup Instance PostgreSQL to be created.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val location: Output<String>

The location of the source database. Changing this forces a new Backup Instance PostgreSQL to be created.

Link copied to clipboard
val name: Output<String>

The name which should be used for this Backup Instance PostgreSQL. Changing this forces a new Backup Instance PostgreSQL to be created.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val vaultId: Output<String>

The ID of the Backup Vault within which the PostgreSQL Backup Instance should exist. Changing this forces a new Backup Instance PostgreSQL to be created.