Skip to content

azurermManagedDiskSasToken

Manages a Disk SAS Token.

Use this resource to obtain a Shared Access Signature (SAS Token) for an existing Managed Disk.

Shared access signatures allow fine-grained, ephemeral access control to various aspects of Managed Disk similar to blob/storage account container.

With the help of this resource, data from the disk can be copied from managed disk to a storage blob or to some other system without the need of azcopy.

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 azurermResourceGroupTest = new azurerm.resourceGroup.ResourceGroup(
  this,
  "test",
  {
    location: "West Europe",
    name: "testrg",
  }
);
const azurermManagedDiskTest = new azurerm.managedDisk.ManagedDisk(
  this,
  "test_1",
  {
    create_option: "Empty",
    disk_size_gb: "1",
    location: azurermResourceGroupTest.location,
    name: "tst-disk-export",
    resource_group_name: azurermResourceGroupTest.name,
    storage_account_type: "Standard_LRS",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermManagedDiskTest.overrideLogicalId("test");
const azurermManagedDiskSasTokenTest =
  new azurerm.managedDiskSasToken.ManagedDiskSasToken(this, "test_2", {
    access_level: "Read",
    duration_in_seconds: 300,
    managed_disk_id: azurermManagedDiskTest.id,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermManagedDiskSasTokenTest.overrideLogicalId("test");

Arguments Reference

The following arguments are supported:

  • managedDiskId - (Required) The ID of an existing Managed Disk which should be exported. Changing this forces a new resource to be created.

  • durationInSeconds - (Required) The duration for which the export should be allowed. Should be between 30 & 4294967295 seconds. Changing this forces a new resource to be created.

  • accessLevel - (Required) The level of access required on the disk. Supported are Read, Write. Changing this forces a new resource to be created.

Refer to the SAS creation reference from Azure for additional details on the fields above.

Attributes Reference

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

  • id - The ID of the Disk Export resource.

  • sasUrl - The computed Shared Access Signature (SAS) of the Managed Disk.

Timeouts

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

  • create - (Defaults to 30 minutes) Used when creating the Disk.
  • read - (Defaults to 5 minutes) Used when retrieving the Disk.
  • delete - (Defaults to 30 minutes) Used when deleting the Disk.

Import

Disk SAS Token can be imported using the resourceId, e.g.

terraform import azurerm_managed_disk_sas_token.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/disks/manageddisk1