aws.lightsail.InstancePublicPorts
Explore with Pulumi AI
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
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const test = new aws.lightsail.Instance("test", {
    name: "yak_sail",
    availabilityZone: available.names[0],
    blueprintId: "amazon_linux_2",
    bundleId: "nano_3_0",
});
const testInstancePublicPorts = new aws.lightsail.InstancePublicPorts("test", {
    instanceName: test.name,
    portInfos: [{
        protocol: "tcp",
        fromPort: 80,
        toPort: 80,
    }],
});
import pulumi
import pulumi_aws as aws
test = aws.lightsail.Instance("test",
    name="yak_sail",
    availability_zone=available["names"],
    blueprint_id="amazon_linux_2",
    bundle_id="nano_3_0")
test_instance_public_ports = aws.lightsail.InstancePublicPorts("test",
    instance_name=test.name,
    port_infos=[{
        "protocol": "tcp",
        "from_port": 80,
        "to_port": 80,
    }])
package main
import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lightsail"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		test, err := lightsail.NewInstance(ctx, "test", &lightsail.InstanceArgs{
			Name:             pulumi.String("yak_sail"),
			AvailabilityZone: pulumi.Any(available.Names[0]),
			BlueprintId:      pulumi.String("amazon_linux_2"),
			BundleId:         pulumi.String("nano_3_0"),
		})
		if err != nil {
			return err
		}
		_, err = lightsail.NewInstancePublicPorts(ctx, "test", &lightsail.InstancePublicPortsArgs{
			InstanceName: test.Name,
			PortInfos: lightsail.InstancePublicPortsPortInfoArray{
				&lightsail.InstancePublicPortsPortInfoArgs{
					Protocol: pulumi.String("tcp"),
					FromPort: pulumi.Int(80),
					ToPort:   pulumi.Int(80),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() => 
{
    var test = new Aws.LightSail.Instance("test", new()
    {
        Name = "yak_sail",
        AvailabilityZone = available.Names[0],
        BlueprintId = "amazon_linux_2",
        BundleId = "nano_3_0",
    });
    var testInstancePublicPorts = new Aws.LightSail.InstancePublicPorts("test", new()
    {
        InstanceName = test.Name,
        PortInfos = new[]
        {
            new Aws.LightSail.Inputs.InstancePublicPortsPortInfoArgs
            {
                Protocol = "tcp",
                FromPort = 80,
                ToPort = 80,
            },
        },
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lightsail.Instance;
import com.pulumi.aws.lightsail.InstanceArgs;
import com.pulumi.aws.lightsail.InstancePublicPorts;
import com.pulumi.aws.lightsail.InstancePublicPortsArgs;
import com.pulumi.aws.lightsail.inputs.InstancePublicPortsPortInfoArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        var test = new Instance("test", InstanceArgs.builder()
            .name("yak_sail")
            .availabilityZone(available.names()[0])
            .blueprintId("amazon_linux_2")
            .bundleId("nano_3_0")
            .build());
        var testInstancePublicPorts = new InstancePublicPorts("testInstancePublicPorts", InstancePublicPortsArgs.builder()
            .instanceName(test.name())
            .portInfos(InstancePublicPortsPortInfoArgs.builder()
                .protocol("tcp")
                .fromPort(80)
                .toPort(80)
                .build())
            .build());
    }
}
resources:
  test:
    type: aws:lightsail:Instance
    properties:
      name: yak_sail
      availabilityZone: ${available.names[0]}
      blueprintId: amazon_linux_2
      bundleId: nano_3_0
  testInstancePublicPorts:
    type: aws:lightsail:InstancePublicPorts
    name: test
    properties:
      instanceName: ${test.name}
      portInfos:
        - protocol: tcp
          fromPort: 80
          toPort: 80
Create InstancePublicPorts Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new InstancePublicPorts(name: string, args: InstancePublicPortsArgs, opts?: CustomResourceOptions);@overload
def InstancePublicPorts(resource_name: str,
                        args: InstancePublicPortsArgs,
                        opts: Optional[ResourceOptions] = None)
@overload
def InstancePublicPorts(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        instance_name: Optional[str] = None,
                        port_infos: Optional[Sequence[InstancePublicPortsPortInfoArgs]] = None)func NewInstancePublicPorts(ctx *Context, name string, args InstancePublicPortsArgs, opts ...ResourceOption) (*InstancePublicPorts, error)public InstancePublicPorts(string name, InstancePublicPortsArgs args, CustomResourceOptions? opts = null)
public InstancePublicPorts(String name, InstancePublicPortsArgs args)
public InstancePublicPorts(String name, InstancePublicPortsArgs args, CustomResourceOptions options)
type: aws:lightsail:InstancePublicPorts
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args InstancePublicPortsArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args InstancePublicPortsArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args InstancePublicPortsArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args InstancePublicPortsArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args InstancePublicPortsArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var instancePublicPortsResource = new Aws.LightSail.InstancePublicPorts("instancePublicPortsResource", new()
{
    InstanceName = "string",
    PortInfos = new[]
    {
        new Aws.LightSail.Inputs.InstancePublicPortsPortInfoArgs
        {
            FromPort = 0,
            Protocol = "string",
            ToPort = 0,
            CidrListAliases = new[]
            {
                "string",
            },
            Cidrs = new[]
            {
                "string",
            },
            Ipv6Cidrs = new[]
            {
                "string",
            },
        },
    },
});
example, err := lightsail.NewInstancePublicPorts(ctx, "instancePublicPortsResource", &lightsail.InstancePublicPortsArgs{
	InstanceName: pulumi.String("string"),
	PortInfos: lightsail.InstancePublicPortsPortInfoArray{
		&lightsail.InstancePublicPortsPortInfoArgs{
			FromPort: pulumi.Int(0),
			Protocol: pulumi.String("string"),
			ToPort:   pulumi.Int(0),
			CidrListAliases: pulumi.StringArray{
				pulumi.String("string"),
			},
			Cidrs: pulumi.StringArray{
				pulumi.String("string"),
			},
			Ipv6Cidrs: pulumi.StringArray{
				pulumi.String("string"),
			},
		},
	},
})
var instancePublicPortsResource = new InstancePublicPorts("instancePublicPortsResource", InstancePublicPortsArgs.builder()
    .instanceName("string")
    .portInfos(InstancePublicPortsPortInfoArgs.builder()
        .fromPort(0)
        .protocol("string")
        .toPort(0)
        .cidrListAliases("string")
        .cidrs("string")
        .ipv6Cidrs("string")
        .build())
    .build());
instance_public_ports_resource = aws.lightsail.InstancePublicPorts("instancePublicPortsResource",
    instance_name="string",
    port_infos=[{
        "from_port": 0,
        "protocol": "string",
        "to_port": 0,
        "cidr_list_aliases": ["string"],
        "cidrs": ["string"],
        "ipv6_cidrs": ["string"],
    }])
const instancePublicPortsResource = new aws.lightsail.InstancePublicPorts("instancePublicPortsResource", {
    instanceName: "string",
    portInfos: [{
        fromPort: 0,
        protocol: "string",
        toPort: 0,
        cidrListAliases: ["string"],
        cidrs: ["string"],
        ipv6Cidrs: ["string"],
    }],
});
type: aws:lightsail:InstancePublicPorts
properties:
    instanceName: string
    portInfos:
        - cidrListAliases:
            - string
          cidrs:
            - string
          fromPort: 0
          ipv6Cidrs:
            - string
          protocol: string
          toPort: 0
InstancePublicPorts Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The InstancePublicPorts resource accepts the following input properties:
- InstanceName string
- Name of the Lightsail Instance.
- PortInfos List<InstancePublic Ports Port Info> 
- Configuration block with port information. AWS closes all currently open ports that are not included in the port_info. Detailed below.
- InstanceName string
- Name of the Lightsail Instance.
- PortInfos []InstancePublic Ports Port Info Args 
- Configuration block with port information. AWS closes all currently open ports that are not included in the port_info. Detailed below.
- instanceName String
- Name of the Lightsail Instance.
- portInfos List<InstancePublic Ports Port Info> 
- Configuration block with port information. AWS closes all currently open ports that are not included in the port_info. Detailed below.
- instanceName string
- Name of the Lightsail Instance.
- portInfos InstancePublic Ports Port Info[] 
- Configuration block with port information. AWS closes all currently open ports that are not included in the port_info. Detailed below.
- instance_name str
- Name of the Lightsail Instance.
- port_infos Sequence[InstancePublic Ports Port Info Args] 
- Configuration block with port information. AWS closes all currently open ports that are not included in the port_info. Detailed below.
- instanceName String
- Name of the Lightsail Instance.
- portInfos List<Property Map>
- Configuration block with port information. AWS closes all currently open ports that are not included in the port_info. Detailed below.
Outputs
All input properties are implicitly available as output properties. Additionally, the InstancePublicPorts resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing InstancePublicPorts Resource
Get an existing InstancePublicPorts resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: InstancePublicPortsState, opts?: CustomResourceOptions): InstancePublicPorts@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        instance_name: Optional[str] = None,
        port_infos: Optional[Sequence[InstancePublicPortsPortInfoArgs]] = None) -> InstancePublicPortsfunc GetInstancePublicPorts(ctx *Context, name string, id IDInput, state *InstancePublicPortsState, opts ...ResourceOption) (*InstancePublicPorts, error)public static InstancePublicPorts Get(string name, Input<string> id, InstancePublicPortsState? state, CustomResourceOptions? opts = null)public static InstancePublicPorts get(String name, Output<String> id, InstancePublicPortsState state, CustomResourceOptions options)resources:  _:    type: aws:lightsail:InstancePublicPorts    get:      id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- InstanceName string
- Name of the Lightsail Instance.
- PortInfos List<InstancePublic Ports Port Info> 
- Configuration block with port information. AWS closes all currently open ports that are not included in the port_info. Detailed below.
- InstanceName string
- Name of the Lightsail Instance.
- PortInfos []InstancePublic Ports Port Info Args 
- Configuration block with port information. AWS closes all currently open ports that are not included in the port_info. Detailed below.
- instanceName String
- Name of the Lightsail Instance.
- portInfos List<InstancePublic Ports Port Info> 
- Configuration block with port information. AWS closes all currently open ports that are not included in the port_info. Detailed below.
- instanceName string
- Name of the Lightsail Instance.
- portInfos InstancePublic Ports Port Info[] 
- Configuration block with port information. AWS closes all currently open ports that are not included in the port_info. Detailed below.
- instance_name str
- Name of the Lightsail Instance.
- port_infos Sequence[InstancePublic Ports Port Info Args] 
- Configuration block with port information. AWS closes all currently open ports that are not included in the port_info. Detailed below.
- instanceName String
- Name of the Lightsail Instance.
- portInfos List<Property Map>
- Configuration block with port information. AWS closes all currently open ports that are not included in the port_info. Detailed below.
Supporting Types
InstancePublicPortsPortInfo, InstancePublicPortsPortInfoArgs          
- FromPort int
- First port in a range of open ports on an instance.
- Protocol string
- IP protocol name. Valid values are tcp,all,udp, andicmp.
- ToPort int
- Last port in a range of open ports on an instance. - The following arguments are optional: 
- CidrList List<string>Aliases 
- Set of CIDR aliases that define access for a preconfigured range of IP addresses.
- Cidrs List<string>
- Set of CIDR blocks.
- Ipv6Cidrs List<string>
- FromPort int
- First port in a range of open ports on an instance.
- Protocol string
- IP protocol name. Valid values are tcp,all,udp, andicmp.
- ToPort int
- Last port in a range of open ports on an instance. - The following arguments are optional: 
- CidrList []stringAliases 
- Set of CIDR aliases that define access for a preconfigured range of IP addresses.
- Cidrs []string
- Set of CIDR blocks.
- Ipv6Cidrs []string
- fromPort Integer
- First port in a range of open ports on an instance.
- protocol String
- IP protocol name. Valid values are tcp,all,udp, andicmp.
- toPort Integer
- Last port in a range of open ports on an instance. - The following arguments are optional: 
- cidrList List<String>Aliases 
- Set of CIDR aliases that define access for a preconfigured range of IP addresses.
- cidrs List<String>
- Set of CIDR blocks.
- ipv6Cidrs List<String>
- fromPort number
- First port in a range of open ports on an instance.
- protocol string
- IP protocol name. Valid values are tcp,all,udp, andicmp.
- toPort number
- Last port in a range of open ports on an instance. - The following arguments are optional: 
- cidrList string[]Aliases 
- Set of CIDR aliases that define access for a preconfigured range of IP addresses.
- cidrs string[]
- Set of CIDR blocks.
- ipv6Cidrs string[]
- from_port int
- First port in a range of open ports on an instance.
- protocol str
- IP protocol name. Valid values are tcp,all,udp, andicmp.
- to_port int
- Last port in a range of open ports on an instance. - The following arguments are optional: 
- cidr_list_ Sequence[str]aliases 
- Set of CIDR aliases that define access for a preconfigured range of IP addresses.
- cidrs Sequence[str]
- Set of CIDR blocks.
- ipv6_cidrs Sequence[str]
- fromPort Number
- First port in a range of open ports on an instance.
- protocol String
- IP protocol name. Valid values are tcp,all,udp, andicmp.
- toPort Number
- Last port in a range of open ports on an instance. - The following arguments are optional: 
- cidrList List<String>Aliases 
- Set of CIDR aliases that define access for a preconfigured range of IP addresses.
- cidrs List<String>
- Set of CIDR blocks.
- ipv6Cidrs List<String>
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the awsTerraform Provider.