Skip to content

Resource: awsLightsailDiskAttachment

Attaches a Lightsail disk to a Lightsail Instance

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const dataAwsAvailabilityZonesAvailable =
  new aws.dataAwsAvailabilityZones.DataAwsAvailabilityZones(this, "available", {
    filter: [
      {
        name: "opt-in-status",
        values: ["opt-in-not-required"],
      },
    ],
    state: "available",
  });
const awsLightsailDiskTest = new aws.lightsailDisk.LightsailDisk(this, "test", {
  availabilityZone: `\${${dataAwsAvailabilityZonesAvailable.names.fqn}[0]}`,
  name: "test-disk",
  sizeInGb: 8,
});
const awsLightsailInstanceTest = new aws.lightsailInstance.LightsailInstance(
  this,
  "test_2",
  {
    availabilityZone: `\${${dataAwsAvailabilityZonesAvailable.names.fqn}[0]}`,
    blueprintId: "amazon_linux_2",
    bundleId: "nano_1_0",
    name: "test-instance",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsLightsailInstanceTest.overrideLogicalId("test");
const awsLightsailDiskAttachmentTest =
  new aws.lightsailDiskAttachment.LightsailDiskAttachment(this, "test_3", {
    diskName: awsLightsailDiskTest.name,
    diskPath: "/dev/xvdf",
    instanceName: awsLightsailInstanceTest.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.*/
awsLightsailDiskAttachmentTest.overrideLogicalId("test");

Argument Reference

The following arguments are supported:

  • diskName - (Required) The name of the Lightsail Disk.
  • instanceName - (Required) The name of the Lightsail Instance to attach to.
  • diskPath - (Required) The disk path to expose to the instance.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - A combination of attributes to create a unique id: diskName,instanceName

Import

awsLightsailDisk can be imported by using the id attribute, e.g.,

$ terraform import aws_lightsail_disk_attachment.test test-disk,test-instance