com.pulumi.azure.siterecovery.ReplicationRecoveryPlan Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure Show documentation
Show all versions of azure Show documentation
A Pulumi package for creating and managing Microsoft Azure cloud resources, based on the Terraform azurerm provider. We recommend using the [Azure Native provider](https://github.com/pulumi/pulumi-azure-native) to provision Azure infrastructure. Azure Native provides complete coverage of Azure resources and same-day access to new resources and resource updates.
// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package com.pulumi.azure.siterecovery;
import com.pulumi.azure.Utilities;
import com.pulumi.azure.siterecovery.ReplicationRecoveryPlanArgs;
import com.pulumi.azure.siterecovery.inputs.ReplicationRecoveryPlanState;
import com.pulumi.azure.siterecovery.outputs.ReplicationRecoveryPlanAzureToAzureSettings;
import com.pulumi.azure.siterecovery.outputs.ReplicationRecoveryPlanBootRecoveryGroup;
import com.pulumi.azure.siterecovery.outputs.ReplicationRecoveryPlanFailoverRecoveryGroup;
import com.pulumi.azure.siterecovery.outputs.ReplicationRecoveryPlanShutdownRecoveryGroup;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.String;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
/**
* Manages a Site Recovery Replication Recovery Plan within a Recovery Services vault. A recovery plan gathers machines into recovery groups for the purpose of failover.
*
* ## Example Usage
*
* <!--Start PulumiCodeChooser -->
*
* {@code
* 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.network.VirtualNetwork;
* import com.pulumi.azure.network.VirtualNetworkArgs;
* import com.pulumi.azure.network.Subnet;
* import com.pulumi.azure.network.SubnetArgs;
* import com.pulumi.azure.network.PublicIp;
* import com.pulumi.azure.network.PublicIpArgs;
* import com.pulumi.azure.network.NetworkInterface;
* import com.pulumi.azure.network.NetworkInterfaceArgs;
* import com.pulumi.azure.network.inputs.NetworkInterfaceIpConfigurationArgs;
* import com.pulumi.azure.compute.VirtualMachine;
* import com.pulumi.azure.compute.VirtualMachineArgs;
* import com.pulumi.azure.compute.inputs.VirtualMachineStorageImageReferenceArgs;
* import com.pulumi.azure.compute.inputs.VirtualMachineStorageOsDiskArgs;
* import com.pulumi.azure.compute.inputs.VirtualMachineOsProfileArgs;
* import com.pulumi.azure.compute.inputs.VirtualMachineOsProfileLinuxConfigArgs;
* import com.pulumi.azure.recoveryservices.Vault;
* import com.pulumi.azure.recoveryservices.VaultArgs;
* import com.pulumi.azure.siterecovery.Fabric;
* import com.pulumi.azure.siterecovery.FabricArgs;
* import com.pulumi.azure.siterecovery.ProtectionContainer;
* import com.pulumi.azure.siterecovery.ProtectionContainerArgs;
* import com.pulumi.azure.siterecovery.ReplicationPolicy;
* import com.pulumi.azure.siterecovery.ReplicationPolicyArgs;
* import com.pulumi.azure.siterecovery.ProtectionContainerMapping;
* import com.pulumi.azure.siterecovery.ProtectionContainerMappingArgs;
* import com.pulumi.azure.siterecovery.NetworkMapping;
* import com.pulumi.azure.siterecovery.NetworkMappingArgs;
* import com.pulumi.azure.storage.Account;
* import com.pulumi.azure.storage.AccountArgs;
* import com.pulumi.azure.siterecovery.ReplicatedVM;
* import com.pulumi.azure.siterecovery.ReplicatedVMArgs;
* import com.pulumi.azure.siterecovery.inputs.ReplicatedVMManagedDiskArgs;
* import com.pulumi.azure.siterecovery.inputs.ReplicatedVMNetworkInterfaceArgs;
* import com.pulumi.azure.siterecovery.ReplicationRecoveryPlan;
* import com.pulumi.azure.siterecovery.ReplicationRecoveryPlanArgs;
* import com.pulumi.azure.siterecovery.inputs.ReplicationRecoveryPlanShutdownRecoveryGroupArgs;
* import com.pulumi.azure.siterecovery.inputs.ReplicationRecoveryPlanFailoverRecoveryGroupArgs;
* import com.pulumi.azure.siterecovery.inputs.ReplicationRecoveryPlanBootRecoveryGroupArgs;
* import com.pulumi.resources.CustomResourceOptions;
* 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 primary = new ResourceGroup("primary", ResourceGroupArgs.builder()
* .name("tfex-replicated-vm-primary")
* .location("West US")
* .build());
*
* var secondary = new ResourceGroup("secondary", ResourceGroupArgs.builder()
* .name("tfex-replicated-vm-secondary")
* .location("East US")
* .build());
*
* var primaryVirtualNetwork = new VirtualNetwork("primaryVirtualNetwork", VirtualNetworkArgs.builder()
* .name("network1")
* .resourceGroupName(primary.name())
* .addressSpaces("192.168.1.0/24")
* .location(primary.location())
* .build());
*
* var primarySubnet = new Subnet("primarySubnet", SubnetArgs.builder()
* .name("network1-subnet")
* .resourceGroupName(primary.name())
* .virtualNetworkName(primaryVirtualNetwork.name())
* .addressPrefixes("192.168.1.0/24")
* .build());
*
* var primaryPublicIp = new PublicIp("primaryPublicIp", PublicIpArgs.builder()
* .name("vm-public-ip-primary")
* .allocationMethod("Static")
* .location(primary.location())
* .resourceGroupName(primary.name())
* .sku("Basic")
* .build());
*
* var vmNetworkInterface = new NetworkInterface("vmNetworkInterface", NetworkInterfaceArgs.builder()
* .name("vm-nic")
* .location(primary.location())
* .resourceGroupName(primary.name())
* .ipConfigurations(NetworkInterfaceIpConfigurationArgs.builder()
* .name("vm")
* .subnetId(primarySubnet.id())
* .privateIpAddressAllocation("Dynamic")
* .publicIpAddressId(primaryPublicIp.id())
* .build())
* .build());
*
* var vm = new VirtualMachine("vm", VirtualMachineArgs.builder()
* .name("vm")
* .location(primary.location())
* .resourceGroupName(primary.name())
* .vmSize("Standard_B1s")
* .networkInterfaceIds(vmNetworkInterface.id())
* .storageImageReference(VirtualMachineStorageImageReferenceArgs.builder()
* .publisher("Canonical")
* .offer("0001-com-ubuntu-server-jammy")
* .sku("22_04-lts")
* .version("latest")
* .build())
* .storageOsDisk(VirtualMachineStorageOsDiskArgs.builder()
* .name("vm-os-disk")
* .osType("Linux")
* .caching("ReadWrite")
* .createOption("FromImage")
* .managedDiskType("Premium_LRS")
* .build())
* .osProfile(VirtualMachineOsProfileArgs.builder()
* .adminUsername("test-admin-123")
* .adminPassword("test-pwd-123")
* .computerName("vm")
* .build())
* .osProfileLinuxConfig(VirtualMachineOsProfileLinuxConfigArgs.builder()
* .disablePasswordAuthentication(false)
* .build())
* .build());
*
* var vault = new Vault("vault", VaultArgs.builder()
* .name("example-recovery-vault")
* .location(secondary.location())
* .resourceGroupName(secondary.name())
* .sku("Standard")
* .build());
*
* var primaryFabric = new Fabric("primaryFabric", FabricArgs.builder()
* .name("primary-fabric")
* .resourceGroupName(secondary.name())
* .recoveryVaultName(vault.name())
* .location(primary.location())
* .build());
*
* var secondaryFabric = new Fabric("secondaryFabric", FabricArgs.builder()
* .name("secondary-fabric")
* .resourceGroupName(secondary.name())
* .recoveryVaultName(vault.name())
* .location(secondary.location())
* .build());
*
* var primaryProtectionContainer = new ProtectionContainer("primaryProtectionContainer", ProtectionContainerArgs.builder()
* .name("primary-protection-container")
* .resourceGroupName(secondary.name())
* .recoveryVaultName(vault.name())
* .recoveryFabricName(primaryFabric.name())
* .build());
*
* var secondaryProtectionContainer = new ProtectionContainer("secondaryProtectionContainer", ProtectionContainerArgs.builder()
* .name("secondary-protection-container")
* .resourceGroupName(secondary.name())
* .recoveryVaultName(vault.name())
* .recoveryFabricName(secondaryFabric.name())
* .build());
*
* var policy = new ReplicationPolicy("policy", ReplicationPolicyArgs.builder()
* .name("policy")
* .resourceGroupName(secondary.name())
* .recoveryVaultName(vault.name())
* .recoveryPointRetentionInMinutes(24 * 60)
* .applicationConsistentSnapshotFrequencyInMinutes(4 * 60)
* .build());
*
* var container_mapping = new ProtectionContainerMapping("container-mapping", ProtectionContainerMappingArgs.builder()
* .name("container-mapping")
* .resourceGroupName(secondary.name())
* .recoveryVaultName(vault.name())
* .recoveryFabricName(primaryFabric.name())
* .recoverySourceProtectionContainerName(primaryProtectionContainer.name())
* .recoveryTargetProtectionContainerId(secondaryProtectionContainer.id())
* .recoveryReplicationPolicyId(policy.id())
* .build());
*
* var secondaryVirtualNetwork = new VirtualNetwork("secondaryVirtualNetwork", VirtualNetworkArgs.builder()
* .name("network2")
* .resourceGroupName(secondary.name())
* .addressSpaces("192.168.2.0/24")
* .location(secondary.location())
* .build());
*
* var network_mapping = new NetworkMapping("network-mapping", NetworkMappingArgs.builder()
* .name("network-mapping")
* .resourceGroupName(secondary.name())
* .recoveryVaultName(vault.name())
* .sourceRecoveryFabricName(primaryFabric.name())
* .targetRecoveryFabricName(secondaryFabric.name())
* .sourceNetworkId(primaryVirtualNetwork.id())
* .targetNetworkId(secondaryVirtualNetwork.id())
* .build());
*
* var primaryAccount = new Account("primaryAccount", AccountArgs.builder()
* .name("primaryrecoverycache")
* .location(primary.location())
* .resourceGroupName(primary.name())
* .accountTier("Standard")
* .accountReplicationType("LRS")
* .build());
*
* var secondarySubnet = new Subnet("secondarySubnet", SubnetArgs.builder()
* .name("network2-subnet")
* .resourceGroupName(secondary.name())
* .virtualNetworkName(secondaryVirtualNetwork.name())
* .addressPrefixes("192.168.2.0/24")
* .build());
*
* var secondaryPublicIp = new PublicIp("secondaryPublicIp", PublicIpArgs.builder()
* .name("vm-public-ip-secondary")
* .allocationMethod("Static")
* .location(secondary.location())
* .resourceGroupName(secondary.name())
* .sku("Basic")
* .build());
*
* var vm_replication = new ReplicatedVM("vm-replication", ReplicatedVMArgs.builder()
* .name("vm-replication")
* .resourceGroupName(secondary.name())
* .recoveryVaultName(vault.name())
* .sourceRecoveryFabricName(primaryFabric.name())
* .sourceVmId(vm.id())
* .recoveryReplicationPolicyId(policy.id())
* .sourceRecoveryProtectionContainerName(primaryProtectionContainer.name())
* .targetResourceGroupId(secondary.id())
* .targetRecoveryFabricId(secondaryFabric.id())
* .targetRecoveryProtectionContainerId(secondaryProtectionContainer.id())
* .managedDisks(ReplicatedVMManagedDiskArgs.builder()
* .diskId(vm.storageOsDisk().applyValue(storageOsDisk -> storageOsDisk.managedDiskId()))
* .stagingStorageAccountId(primaryAccount.id())
* .targetResourceGroupId(secondary.id())
* .targetDiskType("Premium_LRS")
* .targetReplicaDiskType("Premium_LRS")
* .build())
* .networkInterfaces(ReplicatedVMNetworkInterfaceArgs.builder()
* .sourceNetworkInterfaceId(vmNetworkInterface.id())
* .targetSubnetName(secondarySubnet.name())
* .recoveryPublicIpAddressId(secondaryPublicIp.id())
* .build())
* .build(), CustomResourceOptions.builder()
* .dependsOn(
* container_mapping,
* network_mapping)
* .build());
*
* var example = new ReplicationRecoveryPlan("example", ReplicationRecoveryPlanArgs.builder()
* .name("example-recover-plan")
* .recoveryVaultId(vault.id())
* .sourceRecoveryFabricId(primaryFabric.id())
* .targetRecoveryFabricId(secondaryFabric.id())
* .shutdownRecoveryGroup()
* .failoverRecoveryGroup()
* .bootRecoveryGroups(ReplicationRecoveryPlanBootRecoveryGroupArgs.builder()
* .replicatedProtectedItems(vm_replication.id())
* .build())
* .build());
*
* }
* }
* }
*
* <!--End PulumiCodeChooser -->
*
* ## Import
*
* Site Recovery Fabric can be imported using the `resource id`, e.g.
*
* ```sh
* $ pulumi import azure:siterecovery/replicationRecoveryPlan:ReplicationRecoveryPlan azurerm_site_recovery_replication_recovery_plan.example /subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/groupName/providers/Microsoft.RecoveryServices/vaults/vaultName/replicationRecoveryPlans/planName
* ```
*
*/
@ResourceType(type="azure:siterecovery/replicationRecoveryPlan:ReplicationRecoveryPlan")
public class ReplicationRecoveryPlan extends com.pulumi.resources.CustomResource {
/**
* An `azure_to_azure_settings` block as defined below.
*
*/
@Export(name="azureToAzureSettings", refs={ReplicationRecoveryPlanAzureToAzureSettings.class}, tree="[0]")
private Output* @Nullable */ ReplicationRecoveryPlanAzureToAzureSettings> azureToAzureSettings;
/**
* @return An `azure_to_azure_settings` block as defined below.
*
*/
public Output> azureToAzureSettings() {
return Codegen.optional(this.azureToAzureSettings);
}
/**
* One or more `boot_recovery_group` blocks as defined below.
*
* > **NOTE:** At least one `boot_recovery_group` block will be required in the next major version of the AzureRM Provider.
*
*/
@Export(name="bootRecoveryGroups", refs={List.class,ReplicationRecoveryPlanBootRecoveryGroup.class}, tree="[0,1]")
private Output> bootRecoveryGroups;
/**
* @return One or more `boot_recovery_group` blocks as defined below.
*
* > **NOTE:** At least one `boot_recovery_group` block will be required in the next major version of the AzureRM Provider.
*
*/
public Output> bootRecoveryGroups() {
return this.bootRecoveryGroups;
}
/**
* One `failover_recovery_group` block as defined below.
*
* > **NOTE:** `failover_recovery_group` will be required in the next major version of the AzureRM Provider.
*
*/
@Export(name="failoverRecoveryGroup", refs={ReplicationRecoveryPlanFailoverRecoveryGroup.class}, tree="[0]")
private Output failoverRecoveryGroup;
/**
* @return One `failover_recovery_group` block as defined below.
*
* > **NOTE:** `failover_recovery_group` will be required in the next major version of the AzureRM Provider.
*
*/
public Output failoverRecoveryGroup() {
return this.failoverRecoveryGroup;
}
/**
* The name of the Replication Plan. The name can contain only letters, numbers, and hyphens. It should start with a letter and end with a letter or a number. Can be a maximum of 63 characters. Changing this forces a new resource to be created.
*
*/
@Export(name="name", refs={String.class}, tree="[0]")
private Output name;
/**
* @return The name of the Replication Plan. The name can contain only letters, numbers, and hyphens. It should start with a letter and end with a letter or a number. Can be a maximum of 63 characters. Changing this forces a new resource to be created.
*
*/
public Output name() {
return this.name;
}
/**
* The ID of the vault that should be updated. Changing this forces a new resource to be created.
*
*/
@Export(name="recoveryVaultId", refs={String.class}, tree="[0]")
private Output recoveryVaultId;
/**
* @return The ID of the vault that should be updated. Changing this forces a new resource to be created.
*
*/
public Output recoveryVaultId() {
return this.recoveryVaultId;
}
/**
* One `shutdown_recovery_group` block as defined below.
*
* > **NOTE:** `shutdown_recovery_group` will be required in the next major version of the AzureRM Provider.
*
*/
@Export(name="shutdownRecoveryGroup", refs={ReplicationRecoveryPlanShutdownRecoveryGroup.class}, tree="[0]")
private Output shutdownRecoveryGroup;
/**
* @return One `shutdown_recovery_group` block as defined below.
*
* > **NOTE:** `shutdown_recovery_group` will be required in the next major version of the AzureRM Provider.
*
*/
public Output shutdownRecoveryGroup() {
return this.shutdownRecoveryGroup;
}
/**
* ID of source fabric to be recovered from. Changing this forces a new Replication Plan to be created.
*
*/
@Export(name="sourceRecoveryFabricId", refs={String.class}, tree="[0]")
private Output sourceRecoveryFabricId;
/**
* @return ID of source fabric to be recovered from. Changing this forces a new Replication Plan to be created.
*
*/
public Output sourceRecoveryFabricId() {
return this.sourceRecoveryFabricId;
}
/**
* ID of target fabric to recover. Changing this forces a new Replication Plan to be created.
*
*/
@Export(name="targetRecoveryFabricId", refs={String.class}, tree="[0]")
private Output targetRecoveryFabricId;
/**
* @return ID of target fabric to recover. Changing this forces a new Replication Plan to be created.
*
*/
public Output targetRecoveryFabricId() {
return this.targetRecoveryFabricId;
}
/**
*
* @param name The _unique_ name of the resulting resource.
*/
public ReplicationRecoveryPlan(java.lang.String name) {
this(name, ReplicationRecoveryPlanArgs.Empty);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
*/
public ReplicationRecoveryPlan(java.lang.String name, ReplicationRecoveryPlanArgs args) {
this(name, args, null);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
* @param options A bag of options that control this resource's behavior.
*/
public ReplicationRecoveryPlan(java.lang.String name, ReplicationRecoveryPlanArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("azure:siterecovery/replicationRecoveryPlan:ReplicationRecoveryPlan", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false);
}
private ReplicationRecoveryPlan(java.lang.String name, Output id, @Nullable ReplicationRecoveryPlanState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("azure:siterecovery/replicationRecoveryPlan:ReplicationRecoveryPlan", name, state, makeResourceOptions(options, id), false);
}
private static ReplicationRecoveryPlanArgs makeArgs(ReplicationRecoveryPlanArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
if (options != null && options.getUrn().isPresent()) {
return null;
}
return args == null ? ReplicationRecoveryPlanArgs.Empty : args;
}
private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) {
var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
.version(Utilities.getVersion())
.build();
return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
}
/**
* Get an existing Host resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state
* @param options Optional settings to control the behavior of the CustomResource.
*/
public static ReplicationRecoveryPlan get(java.lang.String name, Output id, @Nullable ReplicationRecoveryPlanState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
return new ReplicationRecoveryPlan(name, id, state, options);
}
}