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.
resource "aws_lightsail_instance" "test" {
name = "yak_sail"
availability_zone = data.aws_availability_zones.available.names[0]
blueprint_id = "amazon_linux_2"
bundle_id = "nano_3_0"
}
resource "aws_lightsail_instance_public_ports" "test" {
instance_name = aws_lightsail_instance.test.name
port_info {
protocol = "tcp"
from_port = 80
to_port = 80
}
}
The following arguments are required:
instance_name
- (Required) Name of the Lightsail Instance.port_info
- (Required) Configuration block with port information. AWS closes all currently open ports that are not included in the port_info
. Detailed below.The following arguments are required:
from_port
- (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
.to_port
- (Required) Last port in a range of open ports on an instance.The following arguments are optional:
cidrs
- (Optional) Set of CIDR blocks.cidr_list_aliases
- (Optional) Set of CIDR aliases that define access for a preconfigured range of IP addresses.This resource exports the following attributes in addition to the arguments above:
id
- ID of the resource.