Skip to content

azurermStorageObjectReplication

Manages a Storage Object Replication.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupDst = new azurerm.resourceGroup.ResourceGroup(
  this,
  "dst",
  {
    location: "East US",
    name: "dstResourceGroupName",
  }
);
const azurermResourceGroupSrc = new azurerm.resourceGroup.ResourceGroup(
  this,
  "src",
  {
    location: "West Europe",
    name: "srcResourceGroupName",
  }
);
const azurermStorageAccountDst = new azurerm.storageAccount.StorageAccount(
  this,
  "dst_2",
  {
    account_replication_type: "LRS",
    account_tier: "Standard",
    blob_properties: [
      {
        change_feed_enabled: true,
        versioning_enabled: true,
      },
    ],
    location: azurermResourceGroupDst.location,
    name: "dststorageaccount",
    resource_group_name: azurermResourceGroupDst.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageAccountDst.overrideLogicalId("dst");
const azurermStorageAccountSrc = new azurerm.storageAccount.StorageAccount(
  this,
  "src_3",
  {
    account_replication_type: "LRS",
    account_tier: "Standard",
    blob_properties: [
      {
        change_feed_enabled: true,
        versioning_enabled: true,
      },
    ],
    location: azurermResourceGroupSrc.location,
    name: "srcstorageaccount",
    resource_group_name: azurermResourceGroupSrc.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageAccountSrc.overrideLogicalId("src");
const azurermStorageContainerDst =
  new azurerm.storageContainer.StorageContainer(this, "dst_4", {
    container_access_type: "private",
    name: "dststrcontainer",
    storage_account_name: azurermStorageAccountDst.name,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageContainerDst.overrideLogicalId("dst");
const azurermStorageContainerSrc =
  new azurerm.storageContainer.StorageContainer(this, "src_5", {
    container_access_type: "private",
    name: "srcstrcontainer",
    storage_account_name: azurermStorageAccountSrc.name,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermStorageContainerSrc.overrideLogicalId("src");
new azurerm.storageObjectReplication.StorageObjectReplication(this, "example", {
  destination_storage_account_id: azurermStorageAccountDst.id,
  rules: [
    {
      destination_container_name: azurermStorageContainerDst.name,
      source_container_name: azurermStorageContainerSrc.name,
    },
  ],
  source_storage_account_id: azurermStorageAccountSrc.id,
});

Arguments Reference

The following arguments are supported:

  • sourceStorageAccountId - (Required) The ID of the source storage account. Changing this forces a new Storage Object Replication to be created.

  • destinationStorageAccountId - (Required) The ID of the destination storage account. Changing this forces a new Storage Object Replication to be created.

  • rules - (Required) One or more rules blocks as defined below.


A rules block supports the following:

  • sourceContainerName - (Required) The source storage container name. Changing this forces a new Storage Object Replication to be created.

  • destinationContainerName - (Required) The destination storage container name. Changing this forces a new Storage Object Replication to be created.

  • copyBlobsCreatedAfter - (Optional) The time after which the Block Blobs created will be copies to the destination. Possible values are onlyNewObjects, everything and time in RFC3339 format: 20060102T15:04:00Z.

  • filterOutBlobsWithPrefix - (Optional) Specifies a list of filters prefixes, the blobs whose names begin with which will be replicated.

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:

  • id - The ID of the Storage Object Replication in the destination storage account. It's composed as format sourceObjectReplicationId;destinationObjectReplicationId.

  • sourceObjectReplicationId - The ID of the Object Replication in the source storage account.

  • destinationObjectReplicationId - The ID of the Object Replication in the destination storage account.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Storage Object Replication.
  • read - (Defaults to 5 minutes) Used when retrieving the Storage Object Replication.
  • update - (Defaults to 30 minutes) Used when updating the Storage Object Replication.
  • delete - (Defaults to 30 minutes) Used when deleting the Storage Object Replication.

Import

Storage Object Replication Policies can be imported using the resourceId, e.g.

terraform import azurerm_storage_object_replication.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Storage/storageAccounts/storageAccount1/objectReplicationPolicies/objectReplicationPolicy1;/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group2/providers/Microsoft.Storage/storageAccounts/storageAccount2/objectReplicationPolicies/objectReplicationPolicy2