Skip to content

Resource: awsLightsailInstancePublicPorts

Opens ports for a specific Amazon Lightsail instance, and specifies the IP addresses allowed to connect to the instance through the ports, and the protocol.

-> See What is Amazon Lightsail? for more information.

\~> Note: Lightsail is currently only supported in a limited number of AWS Regions, please see "Regions and Availability Zones in Amazon Lightsail" for more details.

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 awsLightsailInstanceTest = new aws.lightsailInstance.LightsailInstance(
  this,
  "test",
  {
    availabilityZone: "${data.aws_availability_zones.available.names[0]}",
    blueprintId: "amazon_linux_2",
    bundleId: "nano_1_0",
    name: "yak_sail",
  }
);
const awsLightsailInstancePublicPortsTest =
  new aws.lightsailInstancePublicPorts.LightsailInstancePublicPorts(
    this,
    "test_1",
    {
      instanceName: awsLightsailInstanceTest.name,
      portInfo: [
        {
          fromPort: 80,
          protocol: "tcp",
          toPort: 80,
        },
      ],
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsLightsailInstancePublicPortsTest.overrideLogicalId("test");

Argument Reference

The following arguments are required:

  • instanceName - (Required) Name of the Lightsail Instance.
  • portInfo - (Required) Configuration block with port information. AWS closes all currently open ports that are not included in the portInfo. Detailed below.

portInfo

The following arguments are required:

  • fromPort - (Required) First port in a range of open ports on an instance.
  • protocol - (Required) IP protocol name. Valid values are tcp, all, udp, and icmp.
  • toPort - (Required) Last port in a range of open ports on an instance.

The following arguments are optional:

  • cidrs - (Optional) Set of CIDR blocks.
  • cidrListAliases - (Optional) Set of CIDR aliases that define access for a preconfigured range of IP addresses.

Attributes Reference

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

  • id - ID of the resource.