Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pulumi.azure.backup.kotlin.ProtectedVM.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.azure.backup.kotlin
import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
/**
* Builder for [ProtectedVM].
*/
@PulumiTagMarker
public class ProtectedVMResourceBuilder internal constructor() {
public var name: String? = null
public var args: ProtectedVMArgs = ProtectedVMArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend ProtectedVMArgsBuilder.() -> Unit) {
val builder = ProtectedVMArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
}
internal fun build(): ProtectedVM {
val builtJavaResource = com.pulumi.azure.backup.ProtectedVM(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return ProtectedVM(builtJavaResource)
}
}
/**
* Manages Azure Backup for an Azure VM
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azure from "@pulumi/azure";
* const exampleResourceGroup = new azure.core.ResourceGroup("example", {
* name: "tfex-recovery_vault",
* location: "West Europe",
* });
* const exampleVault = new azure.recoveryservices.Vault("example", {
* name: "tfex-recovery-vault",
* location: exampleResourceGroup.location,
* resourceGroupName: exampleResourceGroup.name,
* sku: "Standard",
* });
* const examplePolicyVM = new azure.backup.PolicyVM("example", {
* name: "tfex-recovery-vault-policy",
* resourceGroupName: exampleResourceGroup.name,
* recoveryVaultName: exampleVault.name,
* backup: {
* frequency: "Daily",
* time: "23:00",
* },
* retentionDaily: {
* count: 10,
* },
* });
* const example = azure.compute.getVirtualMachineOutput({
* name: "example-vm",
* resourceGroupName: exampleResourceGroup.name,
* });
* const vm1 = new azure.backup.ProtectedVM("vm1", {
* resourceGroupName: exampleResourceGroup.name,
* recoveryVaultName: exampleVault.name,
* sourceVmId: example.apply(example => example.id),
* backupPolicyId: examplePolicyVM.id,
* });
* ```
* ```python
* import pulumi
* import pulumi_azure as azure
* example_resource_group = azure.core.ResourceGroup("example",
* name="tfex-recovery_vault",
* location="West Europe")
* example_vault = azure.recoveryservices.Vault("example",
* name="tfex-recovery-vault",
* location=example_resource_group.location,
* resource_group_name=example_resource_group.name,
* sku="Standard")
* example_policy_vm = azure.backup.PolicyVM("example",
* name="tfex-recovery-vault-policy",
* resource_group_name=example_resource_group.name,
* recovery_vault_name=example_vault.name,
* backup={
* "frequency": "Daily",
* "time": "23:00",
* },
* retention_daily={
* "count": 10,
* })
* example = azure.compute.get_virtual_machine_output(name="example-vm",
* resource_group_name=example_resource_group.name)
* vm1 = azure.backup.ProtectedVM("vm1",
* resource_group_name=example_resource_group.name,
* recovery_vault_name=example_vault.name,
* source_vm_id=example.id,
* backup_policy_id=example_policy_vm.id)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Azure = Pulumi.Azure;
* return await Deployment.RunAsync(() =>
* {
* var exampleResourceGroup = new Azure.Core.ResourceGroup("example", new()
* {
* Name = "tfex-recovery_vault",
* Location = "West Europe",
* });
* var exampleVault = new Azure.RecoveryServices.Vault("example", new()
* {
* Name = "tfex-recovery-vault",
* Location = exampleResourceGroup.Location,
* ResourceGroupName = exampleResourceGroup.Name,
* Sku = "Standard",
* });
* var examplePolicyVM = new Azure.Backup.PolicyVM("example", new()
* {
* Name = "tfex-recovery-vault-policy",
* ResourceGroupName = exampleResourceGroup.Name,
* RecoveryVaultName = exampleVault.Name,
* Backup = new Azure.Backup.Inputs.PolicyVMBackupArgs
* {
* Frequency = "Daily",
* Time = "23:00",
* },
* RetentionDaily = new Azure.Backup.Inputs.PolicyVMRetentionDailyArgs
* {
* Count = 10,
* },
* });
* var example = Azure.Compute.GetVirtualMachine.Invoke(new()
* {
* Name = "example-vm",
* ResourceGroupName = exampleResourceGroup.Name,
* });
* var vm1 = new Azure.Backup.ProtectedVM("vm1", new()
* {
* ResourceGroupName = exampleResourceGroup.Name,
* RecoveryVaultName = exampleVault.Name,
* SourceVmId = example.Apply(getVirtualMachineResult => getVirtualMachineResult.Id),
* BackupPolicyId = examplePolicyVM.Id,
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/backup"
* "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/compute"
* "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
* "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/recoveryservices"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* exampleResourceGroup, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
* Name: pulumi.String("tfex-recovery_vault"),
* Location: pulumi.String("West Europe"),
* })
* if err != nil {
* return err
* }
* exampleVault, err := recoveryservices.NewVault(ctx, "example", &recoveryservices.VaultArgs{
* Name: pulumi.String("tfex-recovery-vault"),
* Location: exampleResourceGroup.Location,
* ResourceGroupName: exampleResourceGroup.Name,
* Sku: pulumi.String("Standard"),
* })
* if err != nil {
* return err
* }
* examplePolicyVM, err := backup.NewPolicyVM(ctx, "example", &backup.PolicyVMArgs{
* Name: pulumi.String("tfex-recovery-vault-policy"),
* ResourceGroupName: exampleResourceGroup.Name,
* RecoveryVaultName: exampleVault.Name,
* Backup: &backup.PolicyVMBackupArgs{
* Frequency: pulumi.String("Daily"),
* Time: pulumi.String("23:00"),
* },
* RetentionDaily: &backup.PolicyVMRetentionDailyArgs{
* Count: pulumi.Int(10),
* },
* })
* if err != nil {
* return err
* }
* example := compute.LookupVirtualMachineOutput(ctx, compute.GetVirtualMachineOutputArgs{
* Name: pulumi.String("example-vm"),
* ResourceGroupName: exampleResourceGroup.Name,
* }, nil)
* _, err = backup.NewProtectedVM(ctx, "vm1", &backup.ProtectedVMArgs{
* ResourceGroupName: exampleResourceGroup.Name,
* RecoveryVaultName: exampleVault.Name,
* SourceVmId: pulumi.String(example.ApplyT(func(example compute.GetVirtualMachineResult) (*string, error) {
* return &example.Id, nil
* }).(pulumi.StringPtrOutput)),
* BackupPolicyId: examplePolicyVM.ID(),
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.azure.core.ResourceGroup;
* import com.pulumi.azure.core.ResourceGroupArgs;
* import com.pulumi.azure.recoveryservices.Vault;
* import com.pulumi.azure.recoveryservices.VaultArgs;
* import com.pulumi.azure.backup.PolicyVM;
* import com.pulumi.azure.backup.PolicyVMArgs;
* import com.pulumi.azure.backup.inputs.PolicyVMBackupArgs;
* import com.pulumi.azure.backup.inputs.PolicyVMRetentionDailyArgs;
* import com.pulumi.azure.compute.ComputeFunctions;
* import com.pulumi.azure.compute.inputs.GetVirtualMachineArgs;
* import com.pulumi.azure.backup.ProtectedVM;
* import com.pulumi.azure.backup.ProtectedVMArgs;
* 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) {
* var exampleResourceGroup = new ResourceGroup("exampleResourceGroup", ResourceGroupArgs.builder()
* .name("tfex-recovery_vault")
* .location("West Europe")
* .build());
* var exampleVault = new Vault("exampleVault", VaultArgs.builder()
* .name("tfex-recovery-vault")
* .location(exampleResourceGroup.location())
* .resourceGroupName(exampleResourceGroup.name())
* .sku("Standard")
* .build());
* var examplePolicyVM = new PolicyVM("examplePolicyVM", PolicyVMArgs.builder()
* .name("tfex-recovery-vault-policy")
* .resourceGroupName(exampleResourceGroup.name())
* .recoveryVaultName(exampleVault.name())
* .backup(PolicyVMBackupArgs.builder()
* .frequency("Daily")
* .time("23:00")
* .build())
* .retentionDaily(PolicyVMRetentionDailyArgs.builder()
* .count(10)
* .build())
* .build());
* final var example = ComputeFunctions.getVirtualMachine(GetVirtualMachineArgs.builder()
* .name("example-vm")
* .resourceGroupName(exampleResourceGroup.name())
* .build());
* var vm1 = new ProtectedVM("vm1", ProtectedVMArgs.builder()
* .resourceGroupName(exampleResourceGroup.name())
* .recoveryVaultName(exampleVault.name())
* .sourceVmId(example.applyValue(getVirtualMachineResult -> getVirtualMachineResult).applyValue(example -> example.applyValue(getVirtualMachineResult -> getVirtualMachineResult.id())))
* .backupPolicyId(examplePolicyVM.id())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* exampleResourceGroup:
* type: azure:core:ResourceGroup
* name: example
* properties:
* name: tfex-recovery_vault
* location: West Europe
* exampleVault:
* type: azure:recoveryservices:Vault
* name: example
* properties:
* name: tfex-recovery-vault
* location: ${exampleResourceGroup.location}
* resourceGroupName: ${exampleResourceGroup.name}
* sku: Standard
* examplePolicyVM:
* type: azure:backup:PolicyVM
* name: example
* properties:
* name: tfex-recovery-vault-policy
* resourceGroupName: ${exampleResourceGroup.name}
* recoveryVaultName: ${exampleVault.name}
* backup:
* frequency: Daily
* time: 23:00
* retentionDaily:
* count: 10
* vm1:
* type: azure:backup:ProtectedVM
* properties:
* resourceGroupName: ${exampleResourceGroup.name}
* recoveryVaultName: ${exampleVault.name}
* sourceVmId: ${example.id}
* backupPolicyId: ${examplePolicyVM.id}
* variables:
* example:
* fn::invoke:
* Function: azure:compute:getVirtualMachine
* Arguments:
* name: example-vm
* resourceGroupName: ${exampleResourceGroup.name}
* ```
*
* ## Import
* Recovery Services Protected VMs can be imported using the `resource id`, e.g.
* ```sh
* $ pulumi import azure:backup/protectedVM:ProtectedVM item1 "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.RecoveryServices/vaults/example-recovery-vault/backupFabrics/Azure/protectionContainers/iaasvmcontainer;iaasvmcontainerv2;group1;vm1/protectedItems/vm;iaasvmcontainerv2;group1;vm1"
* ```
* Note the ID requires quoting as there are semicolons
*/
public class ProtectedVM internal constructor(
override val javaResource: com.pulumi.azure.backup.ProtectedVM,
) : KotlinCustomResource(javaResource, ProtectedVMMapper) {
/**
* Specifies the id of the backup policy to use. Required in creation or when `protection_stopped` is not specified.
*/
public val backupPolicyId: Output?
get() = javaResource.backupPolicyId().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* A list of Disks' Logical Unit Numbers(LUN) to be excluded for VM Protection.
*/
public val excludeDiskLuns: Output>?
get() = javaResource.excludeDiskLuns().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 -> args0 })
}).orElse(null)
})
/**
* A list of Disks' Logical Unit Numbers(LUN) to be included for VM Protection.
*/
public val includeDiskLuns: Output>?
get() = javaResource.includeDiskLuns().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 -> args0 })
}).orElse(null)
})
/**
* Specifies Protection state of the backup. Possible values are `Invalid`, `IRPending`, `Protected`, `ProtectionStopped`, `ProtectionError` and `ProtectionPaused`.
*/
public val protectionState: Output
get() = javaResource.protectionState().applyValue({ args0 -> args0 })
/**
* Specifies the name of the Recovery Services Vault to use. Changing this forces a new resource to be created.
*/
public val recoveryVaultName: Output
get() = javaResource.recoveryVaultName().applyValue({ args0 -> args0 })
/**
* Specifies the name of the Resource Group **associated with** the Recovery Services Vault to use. Changing this forces a new resource to be created.
*/
public val resourceGroupName: Output
get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })
/**
* Specifies the ID of the VM to backup. Changing this forces a new resource to be created.
* > **NOTE:** After creation, the `source_vm_id` property can be removed without forcing a new resource to be created; however, setting it to a different ID will create a new resource.
* This allows the source vm to be deleted without having to remove the backup.
*/
public val sourceVmId: Output
get() = javaResource.sourceVmId().applyValue({ args0 -> args0 })
}
public object ProtectedVMMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.azure.backup.ProtectedVM::class == javaResource::class
override fun map(javaResource: Resource): ProtectedVM = ProtectedVM(
javaResource as
com.pulumi.azure.backup.ProtectedVM,
)
}
/**
* @see [ProtectedVM].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [ProtectedVM].
*/
public suspend fun protectedVM(name: String, block: suspend ProtectedVMResourceBuilder.() -> Unit): ProtectedVM {
val builder = ProtectedVMResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [ProtectedVM].
* @param name The _unique_ name of the resulting resource.
*/
public fun protectedVM(name: String): ProtectedVM {
val builder = ProtectedVMResourceBuilder()
builder.name(name)
return builder.build()
}