1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. InstanceGroupNamedPort
Google Cloud Classic v7.26.0 published on Friday, Jun 7, 2024 by Pulumi

gcp.compute.InstanceGroupNamedPort

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.26.0 published on Friday, Jun 7, 2024 by Pulumi

    Mange the named ports setting for a managed instance group without managing the group as whole. This resource is primarily intended for use with GKE-generated groups that shouldn’t otherwise be managed by other tools.

    To get more information about InstanceGroupNamedPort, see:

    Example Usage

    Instance Group Named Port Gke

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const containerNetwork = new gcp.compute.Network("container_network", {
        name: "container-network",
        autoCreateSubnetworks: false,
    });
    const containerSubnetwork = new gcp.compute.Subnetwork("container_subnetwork", {
        name: "container-subnetwork",
        region: "us-central1",
        network: containerNetwork.name,
        ipCidrRange: "10.0.36.0/24",
    });
    const myCluster = new gcp.container.Cluster("my_cluster", {
        name: "my-cluster",
        location: "us-central1-a",
        initialNodeCount: 1,
        network: containerNetwork.name,
        subnetwork: containerSubnetwork.name,
        ipAllocationPolicy: {
            clusterIpv4CidrBlock: "/19",
            servicesIpv4CidrBlock: "/22",
        },
        deletionProtection: true,
    });
    const myPort = new gcp.compute.InstanceGroupNamedPort("my_port", {
        group: myCluster.nodePools.apply(nodePools => nodePools[0].instanceGroupUrls?.[0]),
        zone: "us-central1-a",
        name: "http",
        port: 8080,
    });
    const myPorts = new gcp.compute.InstanceGroupNamedPort("my_ports", {
        group: myCluster.nodePools.apply(nodePools => nodePools[0].instanceGroupUrls?.[0]),
        zone: "us-central1-a",
        name: "https",
        port: 4443,
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    container_network = gcp.compute.Network("container_network",
        name="container-network",
        auto_create_subnetworks=False)
    container_subnetwork = gcp.compute.Subnetwork("container_subnetwork",
        name="container-subnetwork",
        region="us-central1",
        network=container_network.name,
        ip_cidr_range="10.0.36.0/24")
    my_cluster = gcp.container.Cluster("my_cluster",
        name="my-cluster",
        location="us-central1-a",
        initial_node_count=1,
        network=container_network.name,
        subnetwork=container_subnetwork.name,
        ip_allocation_policy=gcp.container.ClusterIpAllocationPolicyArgs(
            cluster_ipv4_cidr_block="/19",
            services_ipv4_cidr_block="/22",
        ),
        deletion_protection=True)
    my_port = gcp.compute.InstanceGroupNamedPort("my_port",
        group=my_cluster.node_pools[0].instance_group_urls[0],
        zone="us-central1-a",
        name="http",
        port=8080)
    my_ports = gcp.compute.InstanceGroupNamedPort("my_ports",
        group=my_cluster.node_pools[0].instance_group_urls[0],
        zone="us-central1-a",
        name="https",
        port=4443)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
    	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/container"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		containerNetwork, err := compute.NewNetwork(ctx, "container_network", &compute.NetworkArgs{
    			Name:                  pulumi.String("container-network"),
    			AutoCreateSubnetworks: pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		containerSubnetwork, err := compute.NewSubnetwork(ctx, "container_subnetwork", &compute.SubnetworkArgs{
    			Name:        pulumi.String("container-subnetwork"),
    			Region:      pulumi.String("us-central1"),
    			Network:     containerNetwork.Name,
    			IpCidrRange: pulumi.String("10.0.36.0/24"),
    		})
    		if err != nil {
    			return err
    		}
    		myCluster, err := container.NewCluster(ctx, "my_cluster", &container.ClusterArgs{
    			Name:             pulumi.String("my-cluster"),
    			Location:         pulumi.String("us-central1-a"),
    			InitialNodeCount: pulumi.Int(1),
    			Network:          containerNetwork.Name,
    			Subnetwork:       containerSubnetwork.Name,
    			IpAllocationPolicy: &container.ClusterIpAllocationPolicyArgs{
    				ClusterIpv4CidrBlock:  pulumi.String("/19"),
    				ServicesIpv4CidrBlock: pulumi.String("/22"),
    			},
    			DeletionProtection: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewInstanceGroupNamedPort(ctx, "my_port", &compute.InstanceGroupNamedPortArgs{
    			Group: myCluster.NodePools.ApplyT(func(nodePools []container.ClusterNodePool) (*string, error) {
    				return &nodePools[0].InstanceGroupUrls[0], nil
    			}).(pulumi.StringPtrOutput),
    			Zone: pulumi.String("us-central1-a"),
    			Name: pulumi.String("http"),
    			Port: pulumi.Int(8080),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewInstanceGroupNamedPort(ctx, "my_ports", &compute.InstanceGroupNamedPortArgs{
    			Group: myCluster.NodePools.ApplyT(func(nodePools []container.ClusterNodePool) (*string, error) {
    				return &nodePools[0].InstanceGroupUrls[0], nil
    			}).(pulumi.StringPtrOutput),
    			Zone: pulumi.String("us-central1-a"),
    			Name: pulumi.String("https"),
    			Port: pulumi.Int(4443),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Gcp = Pulumi.Gcp;
    
    return await Deployment.RunAsync(() => 
    {
        var containerNetwork = new Gcp.Compute.Network("container_network", new()
        {
            Name = "container-network",
            AutoCreateSubnetworks = false,
        });
    
        var containerSubnetwork = new Gcp.Compute.Subnetwork("container_subnetwork", new()
        {
            Name = "container-subnetwork",
            Region = "us-central1",
            Network = containerNetwork.Name,
            IpCidrRange = "10.0.36.0/24",
        });
    
        var myCluster = new Gcp.Container.Cluster("my_cluster", new()
        {
            Name = "my-cluster",
            Location = "us-central1-a",
            InitialNodeCount = 1,
            Network = containerNetwork.Name,
            Subnetwork = containerSubnetwork.Name,
            IpAllocationPolicy = new Gcp.Container.Inputs.ClusterIpAllocationPolicyArgs
            {
                ClusterIpv4CidrBlock = "/19",
                ServicesIpv4CidrBlock = "/22",
            },
            DeletionProtection = true,
        });
    
        var myPort = new Gcp.Compute.InstanceGroupNamedPort("my_port", new()
        {
            Group = myCluster.NodePools.Apply(nodePools => nodePools[0].InstanceGroupUrls[0]),
            Zone = "us-central1-a",
            Name = "http",
            Port = 8080,
        });
    
        var myPorts = new Gcp.Compute.InstanceGroupNamedPort("my_ports", new()
        {
            Group = myCluster.NodePools.Apply(nodePools => nodePools[0].InstanceGroupUrls[0]),
            Zone = "us-central1-a",
            Name = "https",
            Port = 4443,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.compute.Network;
    import com.pulumi.gcp.compute.NetworkArgs;
    import com.pulumi.gcp.compute.Subnetwork;
    import com.pulumi.gcp.compute.SubnetworkArgs;
    import com.pulumi.gcp.container.Cluster;
    import com.pulumi.gcp.container.ClusterArgs;
    import com.pulumi.gcp.container.inputs.ClusterIpAllocationPolicyArgs;
    import com.pulumi.gcp.compute.InstanceGroupNamedPort;
    import com.pulumi.gcp.compute.InstanceGroupNamedPortArgs;
    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 containerNetwork = new Network("containerNetwork", NetworkArgs.builder()
                .name("container-network")
                .autoCreateSubnetworks(false)
                .build());
    
            var containerSubnetwork = new Subnetwork("containerSubnetwork", SubnetworkArgs.builder()
                .name("container-subnetwork")
                .region("us-central1")
                .network(containerNetwork.name())
                .ipCidrRange("10.0.36.0/24")
                .build());
    
            var myCluster = new Cluster("myCluster", ClusterArgs.builder()
                .name("my-cluster")
                .location("us-central1-a")
                .initialNodeCount(1)
                .network(containerNetwork.name())
                .subnetwork(containerSubnetwork.name())
                .ipAllocationPolicy(ClusterIpAllocationPolicyArgs.builder()
                    .clusterIpv4CidrBlock("/19")
                    .servicesIpv4CidrBlock("/22")
                    .build())
                .deletionProtection("true")
                .build());
    
            var myPort = new InstanceGroupNamedPort("myPort", InstanceGroupNamedPortArgs.builder()
                .group(myCluster.nodePools().applyValue(nodePools -> nodePools[0].instanceGroupUrls()[0]))
                .zone("us-central1-a")
                .name("http")
                .port(8080)
                .build());
    
            var myPorts = new InstanceGroupNamedPort("myPorts", InstanceGroupNamedPortArgs.builder()
                .group(myCluster.nodePools().applyValue(nodePools -> nodePools[0].instanceGroupUrls()[0]))
                .zone("us-central1-a")
                .name("https")
                .port(4443)
                .build());
    
        }
    }
    
    resources:
      myPort:
        type: gcp:compute:InstanceGroupNamedPort
        name: my_port
        properties:
          group: ${myCluster.nodePools[0].instanceGroupUrls[0]}
          zone: us-central1-a
          name: http
          port: 8080
      myPorts:
        type: gcp:compute:InstanceGroupNamedPort
        name: my_ports
        properties:
          group: ${myCluster.nodePools[0].instanceGroupUrls[0]}
          zone: us-central1-a
          name: https
          port: 4443
      containerNetwork:
        type: gcp:compute:Network
        name: container_network
        properties:
          name: container-network
          autoCreateSubnetworks: false
      containerSubnetwork:
        type: gcp:compute:Subnetwork
        name: container_subnetwork
        properties:
          name: container-subnetwork
          region: us-central1
          network: ${containerNetwork.name}
          ipCidrRange: 10.0.36.0/24
      myCluster:
        type: gcp:container:Cluster
        name: my_cluster
        properties:
          name: my-cluster
          location: us-central1-a
          initialNodeCount: 1
          network: ${containerNetwork.name}
          subnetwork: ${containerSubnetwork.name}
          ipAllocationPolicy:
            clusterIpv4CidrBlock: /19
            servicesIpv4CidrBlock: /22
          deletionProtection: 'true'
    

    Create InstanceGroupNamedPort Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new InstanceGroupNamedPort(name: string, args: InstanceGroupNamedPortArgs, opts?: CustomResourceOptions);
    @overload
    def InstanceGroupNamedPort(resource_name: str,
                               args: InstanceGroupNamedPortInitArgs,
                               opts: Optional[ResourceOptions] = None)
    
    @overload
    def InstanceGroupNamedPort(resource_name: str,
                               opts: Optional[ResourceOptions] = None,
                               group: Optional[str] = None,
                               port: Optional[int] = None,
                               name: Optional[str] = None,
                               project: Optional[str] = None,
                               zone: Optional[str] = None)
    func NewInstanceGroupNamedPort(ctx *Context, name string, args InstanceGroupNamedPortArgs, opts ...ResourceOption) (*InstanceGroupNamedPort, error)
    public InstanceGroupNamedPort(string name, InstanceGroupNamedPortArgs args, CustomResourceOptions? opts = null)
    public InstanceGroupNamedPort(String name, InstanceGroupNamedPortArgs args)
    public InstanceGroupNamedPort(String name, InstanceGroupNamedPortArgs args, CustomResourceOptions options)
    
    type: gcp:compute:InstanceGroupNamedPort
    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 InstanceGroupNamedPortArgs
    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 InstanceGroupNamedPortInitArgs
    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 InstanceGroupNamedPortArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args InstanceGroupNamedPortArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args InstanceGroupNamedPortArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    var instanceGroupNamedPortResource = new Gcp.Compute.InstanceGroupNamedPort("instanceGroupNamedPortResource", new()
    {
        Group = "string",
        Port = 0,
        Name = "string",
        Project = "string",
        Zone = "string",
    });
    
    example, err := compute.NewInstanceGroupNamedPort(ctx, "instanceGroupNamedPortResource", &compute.InstanceGroupNamedPortArgs{
    	Group:   pulumi.String("string"),
    	Port:    pulumi.Int(0),
    	Name:    pulumi.String("string"),
    	Project: pulumi.String("string"),
    	Zone:    pulumi.String("string"),
    })
    
    var instanceGroupNamedPortResource = new InstanceGroupNamedPort("instanceGroupNamedPortResource", InstanceGroupNamedPortArgs.builder()
        .group("string")
        .port(0)
        .name("string")
        .project("string")
        .zone("string")
        .build());
    
    instance_group_named_port_resource = gcp.compute.InstanceGroupNamedPort("instanceGroupNamedPortResource",
        group="string",
        port=0,
        name="string",
        project="string",
        zone="string")
    
    const instanceGroupNamedPortResource = new gcp.compute.InstanceGroupNamedPort("instanceGroupNamedPortResource", {
        group: "string",
        port: 0,
        name: "string",
        project: "string",
        zone: "string",
    });
    
    type: gcp:compute:InstanceGroupNamedPort
    properties:
        group: string
        name: string
        port: 0
        project: string
        zone: string
    

    InstanceGroupNamedPort Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The InstanceGroupNamedPort resource accepts the following input properties:

    Group string
    The name of the instance group.


    Port int
    The port number, which can be a value between 1 and 65535.
    Name string
    The name for this named port. The name must be 1-63 characters long, and comply with RFC1035.
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    Zone string
    The zone of the instance group.
    Group string
    The name of the instance group.


    Port int
    The port number, which can be a value between 1 and 65535.
    Name string
    The name for this named port. The name must be 1-63 characters long, and comply with RFC1035.
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    Zone string
    The zone of the instance group.
    group String
    The name of the instance group.


    port Integer
    The port number, which can be a value between 1 and 65535.
    name String
    The name for this named port. The name must be 1-63 characters long, and comply with RFC1035.
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    zone String
    The zone of the instance group.
    group string
    The name of the instance group.


    port number
    The port number, which can be a value between 1 and 65535.
    name string
    The name for this named port. The name must be 1-63 characters long, and comply with RFC1035.
    project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    zone string
    The zone of the instance group.
    group str
    The name of the instance group.


    port int
    The port number, which can be a value between 1 and 65535.
    name str
    The name for this named port. The name must be 1-63 characters long, and comply with RFC1035.
    project str
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    zone str
    The zone of the instance group.
    group String
    The name of the instance group.


    port Number
    The port number, which can be a value between 1 and 65535.
    name String
    The name for this named port. The name must be 1-63 characters long, and comply with RFC1035.
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    zone String
    The zone of the instance group.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the InstanceGroupNamedPort 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 InstanceGroupNamedPort Resource

    Get an existing InstanceGroupNamedPort 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?: InstanceGroupNamedPortState, opts?: CustomResourceOptions): InstanceGroupNamedPort
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            group: Optional[str] = None,
            name: Optional[str] = None,
            port: Optional[int] = None,
            project: Optional[str] = None,
            zone: Optional[str] = None) -> InstanceGroupNamedPort
    func GetInstanceGroupNamedPort(ctx *Context, name string, id IDInput, state *InstanceGroupNamedPortState, opts ...ResourceOption) (*InstanceGroupNamedPort, error)
    public static InstanceGroupNamedPort Get(string name, Input<string> id, InstanceGroupNamedPortState? state, CustomResourceOptions? opts = null)
    public static InstanceGroupNamedPort get(String name, Output<String> id, InstanceGroupNamedPortState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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.
    The following state arguments are supported:
    Group string
    The name of the instance group.


    Name string
    The name for this named port. The name must be 1-63 characters long, and comply with RFC1035.
    Port int
    The port number, which can be a value between 1 and 65535.
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    Zone string
    The zone of the instance group.
    Group string
    The name of the instance group.


    Name string
    The name for this named port. The name must be 1-63 characters long, and comply with RFC1035.
    Port int
    The port number, which can be a value between 1 and 65535.
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    Zone string
    The zone of the instance group.
    group String
    The name of the instance group.


    name String
    The name for this named port. The name must be 1-63 characters long, and comply with RFC1035.
    port Integer
    The port number, which can be a value between 1 and 65535.
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    zone String
    The zone of the instance group.
    group string
    The name of the instance group.


    name string
    The name for this named port. The name must be 1-63 characters long, and comply with RFC1035.
    port number
    The port number, which can be a value between 1 and 65535.
    project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    zone string
    The zone of the instance group.
    group str
    The name of the instance group.


    name str
    The name for this named port. The name must be 1-63 characters long, and comply with RFC1035.
    port int
    The port number, which can be a value between 1 and 65535.
    project str
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    zone str
    The zone of the instance group.
    group String
    The name of the instance group.


    name String
    The name for this named port. The name must be 1-63 characters long, and comply with RFC1035.
    port Number
    The port number, which can be a value between 1 and 65535.
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    zone String
    The zone of the instance group.

    Import

    InstanceGroupNamedPort can be imported using any of these accepted formats:

    • projects/{{project}}/zones/{{zone}}/instanceGroups/{{group}}/{{port}}/{{name}}

    • {{project}}/{{zone}}/{{group}}/{{port}}/{{name}}

    • {{zone}}/{{group}}/{{port}}/{{name}}

    • {{group}}/{{port}}/{{name}}

    When using the pulumi import command, InstanceGroupNamedPort can be imported using one of the formats above. For example:

    $ pulumi import gcp:compute/instanceGroupNamedPort:InstanceGroupNamedPort default projects/{{project}}/zones/{{zone}}/instanceGroups/{{group}}/{{port}}/{{name}}
    
    $ pulumi import gcp:compute/instanceGroupNamedPort:InstanceGroupNamedPort default {{project}}/{{zone}}/{{group}}/{{port}}/{{name}}
    
    $ pulumi import gcp:compute/instanceGroupNamedPort:InstanceGroupNamedPort default {{zone}}/{{group}}/{{port}}/{{name}}
    
    $ pulumi import gcp:compute/instanceGroupNamedPort:InstanceGroupNamedPort default {{group}}/{{port}}/{{name}}
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Google Cloud (GCP) Classic pulumi/pulumi-gcp
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the google-beta Terraform Provider.
    gcp logo
    Google Cloud Classic v7.26.0 published on Friday, Jun 7, 2024 by Pulumi