Class InstancePublicPorts


  • public class InstancePublicPorts
    extends com.pulumi.resources.CustomResource
    Manages public ports for a Lightsail instance. Use this resource to open ports for a specific Amazon Lightsail instance and specify the IP addresses allowed to connect to the instance through the ports and the protocol. > See [What is Amazon Lightsail?](https://lightsail.aws.amazon.com/ls/docs/getting-started/article/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"](https://lightsail.aws.amazon.com/ls/docs/overview/article/understanding-regions-and-availability-zones-in-amazon-lightsail) for more details. ## Example Usage
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.AwsFunctions;
     import com.pulumi.aws.inputs.GetAvailabilityZonesArgs;
     import com.pulumi.aws.inputs.GetAvailabilityZonesFilterArgs;
     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.ArrayList;
     import java.util.Arrays;
     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) {
             final var available = AwsFunctions.getAvailabilityZones(GetAvailabilityZonesArgs.builder()
                 .filters(GetAvailabilityZonesFilterArgs.builder()
                     .name("opt-in-status")
                     .values("opt-in-not-required")
                     .build())
                 .state("available")
                 .build());
     
             var example = new Instance("example", InstanceArgs.builder()
                 .name("example-instance")
                 .availabilityZone(available.names()[0])
                 .blueprintId("amazon_linux_2")
                 .bundleId("nano_3_0")
                 .build());
     
             var exampleInstancePublicPorts = new InstancePublicPorts("exampleInstancePublicPorts", InstancePublicPortsArgs.builder()
                 .portInfos(            
                     InstancePublicPortsPortInfoArgs.builder()
                         .protocol("tcp")
                         .fromPort(80)
                         .toPort(80)
                         .build(),
                     InstancePublicPortsPortInfoArgs.builder()
                         .protocol("tcp")
                         .fromPort(443)
                         .toPort(443)
                         .cidrs("192.168.1.0/24")
                         .build())
                 .instanceName(example.name())
                 .build());
     
         }
     }
     
     
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static InstancePublicPorts get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, InstancePublicPortsState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.lang.String> instanceName()  
      com.pulumi.core.Output<java.util.List<InstancePublicPortsPortInfo>> portInfos()  
      com.pulumi.core.Output<java.lang.String> region()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InstancePublicPorts

        public InstancePublicPorts​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • InstancePublicPorts

        public InstancePublicPorts​(java.lang.String name,
                                   InstancePublicPortsArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • InstancePublicPorts

        public InstancePublicPorts​(java.lang.String name,
                                   InstancePublicPortsArgs args,
                                   @Nullable
                                   com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • instanceName

        public com.pulumi.core.Output<java.lang.String> instanceName()
        Returns:
        Name of the instance for which to open ports.
      • portInfos

        public com.pulumi.core.Output<java.util.List<InstancePublicPortsPortInfo>> portInfos()
        Returns:
        Descriptor of the ports to open for the specified instance. AWS closes all currently open ports that are not included in this argument. See `portInfo` Block for details. The following arguments are optional:
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • get

        public static InstancePublicPorts get​(java.lang.String name,
                                              com.pulumi.core.Output<java.lang.String> id,
                                              @Nullable
                                              InstancePublicPortsState state,
                                              @Nullable
                                              com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.