gcp.compute.InstanceGroupNamedPort
Explore with Pulumi AI
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:
- API documentation
- How-to Guides
Example Usage
Instance Group Named Port Gke
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var containerNetwork = new Gcp.Compute.Network("containerNetwork", new()
{
AutoCreateSubnetworks = false,
});
var containerSubnetwork = new Gcp.Compute.Subnetwork("containerSubnetwork", new()
{
Region = "us-central1",
Network = containerNetwork.Name,
IpCidrRange = "10.0.36.0/24",
});
var myCluster = new Gcp.Container.Cluster("myCluster", new()
{
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("myPort", new()
{
Group = myCluster.NodePools.Apply(nodePools => nodePools[0].InstanceGroupUrls[0]),
Zone = "us-central1-a",
Port = 8080,
});
var myPorts = new Gcp.Compute.InstanceGroupNamedPort("myPorts", new()
{
Group = myCluster.NodePools.Apply(nodePools => nodePools[0].InstanceGroupUrls[0]),
Zone = "us-central1-a",
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, "containerNetwork", &compute.NetworkArgs{
AutoCreateSubnetworks: pulumi.Bool(false),
})
if err != nil {
return err
}
containerSubnetwork, err := compute.NewSubnetwork(ctx, "containerSubnetwork", &compute.SubnetworkArgs{
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, "myCluster", &container.ClusterArgs{
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, "myPort", &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"),
Port: pulumi.Int(8080),
})
if err != nil {
return err
}
_, err = compute.NewInstanceGroupNamedPort(ctx, "myPorts", &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"),
Port: pulumi.Int(4443),
})
if err != nil {
return err
}
return nil
})
}
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()
.autoCreateSubnetworks(false)
.build());
var containerSubnetwork = new Subnetwork("containerSubnetwork", SubnetworkArgs.builder()
.region("us-central1")
.network(containerNetwork.name())
.ipCidrRange("10.0.36.0/24")
.build());
var myCluster = new Cluster("myCluster", ClusterArgs.builder()
.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")
.port(8080)
.build());
var myPorts = new InstanceGroupNamedPort("myPorts", InstanceGroupNamedPortArgs.builder()
.group(myCluster.nodePools().applyValue(nodePools -> nodePools[0].instanceGroupUrls()[0]))
.zone("us-central1-a")
.port(4443)
.build());
}
}
import pulumi
import pulumi_gcp as gcp
container_network = gcp.compute.Network("containerNetwork", auto_create_subnetworks=False)
container_subnetwork = gcp.compute.Subnetwork("containerSubnetwork",
region="us-central1",
network=container_network.name,
ip_cidr_range="10.0.36.0/24")
my_cluster = gcp.container.Cluster("myCluster",
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("myPort",
group=my_cluster.node_pools[0].instance_group_urls[0],
zone="us-central1-a",
port=8080)
my_ports = gcp.compute.InstanceGroupNamedPort("myPorts",
group=my_cluster.node_pools[0].instance_group_urls[0],
zone="us-central1-a",
port=4443)
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const containerNetwork = new gcp.compute.Network("containerNetwork", {autoCreateSubnetworks: false});
const containerSubnetwork = new gcp.compute.Subnetwork("containerSubnetwork", {
region: "us-central1",
network: containerNetwork.name,
ipCidrRange: "10.0.36.0/24",
});
const myCluster = new gcp.container.Cluster("myCluster", {
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("myPort", {
group: myCluster.nodePools.apply(nodePools => nodePools[0].instanceGroupUrls?.[0]),
zone: "us-central1-a",
port: 8080,
});
const myPorts = new gcp.compute.InstanceGroupNamedPort("myPorts", {
group: myCluster.nodePools.apply(nodePools => nodePools[0].instanceGroupUrls?.[0]),
zone: "us-central1-a",
port: 4443,
});
resources:
myPort:
type: gcp:compute:InstanceGroupNamedPort
properties:
group: ${myCluster.nodePools[0].instanceGroupUrls[0]}
zone: us-central1-a
port: 8080
myPorts:
type: gcp:compute:InstanceGroupNamedPort
properties:
group: ${myCluster.nodePools[0].instanceGroupUrls[0]}
zone: us-central1-a
port: 4443
containerNetwork:
type: gcp:compute:Network
properties:
autoCreateSubnetworks: false
containerSubnetwork:
type: gcp:compute:Subnetwork
properties:
region: us-central1
network: ${containerNetwork.name}
ipCidrRange: 10.0.36.0/24
myCluster:
type: gcp:container:Cluster
properties:
location: us-central1-a
initialNodeCount: 1
network: ${containerNetwork.name}
subnetwork: ${containerSubnetwork.name}
ipAllocationPolicy:
clusterIpv4CidrBlock: /19
servicesIpv4CidrBlock: /22
deletionProtection: 'true'
Create InstanceGroupNamedPort Resource
new InstanceGroupNamedPort(name: string, args: InstanceGroupNamedPortArgs, opts?: CustomResourceOptions);
@overload
def InstanceGroupNamedPort(resource_name: 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)
@overload
def InstanceGroupNamedPort(resource_name: str,
args: InstanceGroupNamedPortInitArgs,
opts: Optional[ResourceOptions] = 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.
- 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.
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.
- 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}}
In Terraform v1.5.0 and later, use an import
block to import InstanceGroupNamedPort using one of the formats above. For exampletf import {
id = “projects/{{project}}/zones/{{zone}}/instanceGroups/{{group}}/{{port}}/{{name}}”
to = google_compute_instance_group_named_port.default }
$ pulumi import gcp:compute/instanceGroupNamedPort:InstanceGroupNamedPort When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), 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}}
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.