Skip to content

Resource: awsLightsailLbAttachment

Attaches a Lightsail Instance to a Lightsail Load Balancer.

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 awsLightsailLbTest = new aws.lightsailLb.LightsailLb(this, "test", {
  healthCheckPath: "/",
  instancePort: "80",
  name: "test-load-balancer",
  tags: {
    foo: "bar",
  },
});
const dataAwsAvailabilityZonesAvailable =
  new aws.dataAwsAvailabilityZones.DataAwsAvailabilityZones(this, "available", {
    filter: [
      {
        name: "opt-in-status",
        values: ["opt-in-not-required"],
      },
    ],
    state: "available",
  });
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 awsLightsailLbAttachmentTest =
  new aws.lightsailLbAttachment.LightsailLbAttachment(this, "test_3", {
    instanceName: awsLightsailInstanceTest.name,
    lbName: awsLightsailLbTest.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.*/
awsLightsailLbAttachmentTest.overrideLogicalId("test");

Argument Reference

The following arguments are supported:

  • lbName - (Required) The name of the Lightsail load balancer.
  • instanceName - (Required) The name of the instance to attach to the load balancer.

Attributes Reference

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

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

Import

awsLightsailLbAttachment can be imported by using the name attribute, e.g.,

$ terraform import aws_lightsail_lb_attachment.test example-load-balancer,example-instance