InstanceGroupNamedPortCompute class
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
- Official Documentation
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={
"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)
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 main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
"github.com/pulumi/pulumi-gcp/sdk/v9/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
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_compute_instancegroupnamedport" "my_port" {
group = gcp_container_cluster.my_cluster.node_pools[0].instance_group_urls[0]
zone = "us-central1-a"
name = "http"
port = 8080
}
resource "gcp_compute_instancegroupnamedport" "my_ports" {
group = gcp_container_cluster.my_cluster.node_pools[0].instance_group_urls[0]
zone = "us-central1-a"
name = "https"
port = 4443
}
resource "gcp_compute_network" "container_network" {
name = "container-network"
auto_create_subnetworks = false
}
resource "gcp_compute_subnetwork" "container_subnetwork" {
name = "container-subnetwork"
region = "us-central1"
network = gcp_compute_network.container_network.name
ip_cidr_range = "10.0.36.0/24"
}
resource "gcp_container_cluster" "my_cluster" {
name = "my-cluster"
location = "us-central1-a"
initial_node_count = 1
network = gcp_compute_network.container_network.name
subnetwork = gcp_compute_subnetwork.container_subnetwork.name
ip_allocation_policy = {
cluster_ipv4_cidr_block = "/19"
services_ipv4_cidr_block = "/22"
}
deletion_protection = true
}
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.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) {
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.get(0).instanceGroupUrls().get(0)))
.zone("us-central1-a")
.name("http")
.port(8080)
.build());
var myPorts = new InstanceGroupNamedPort("myPorts", InstanceGroupNamedPortArgs.builder()
.group(myCluster.nodePools().applyValue(_nodePools -> _nodePools.get(0).instanceGroupUrls().get(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
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}}
Constructors
- InstanceGroupNamedPortCompute(String name, {InstanceGroupNamedPortArgs? args, CustomResourceOptions? options})
-
Creates a new InstanceGroupNamedPortCompute.
nameThe Pulumi resource name.argsArguments used to configure this InstanceGroupNamedPortCompute. The set of arguments for InstanceGroupNamedPort.optionsResource options controlling this resource's behavior. - InstanceGroupNamedPortCompute.reference(String urn)
- Creates a typed reference to an existing InstanceGroupNamedPortCompute resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
deletionPolicy
↔ Output<
String> -
Whether Terraform will be prevented from destroying the resource. Defaults to DELETE.
When a 'terraform destroy' or 'pulumi up' would delete the resource,
the command will fail if this field is set to "PREVENT" in Terraform state.
When set to "ABANDON", the command will remove the resource from Terraform
management without updating or deleting the resource in the API.
When set to "DELETE", deleting the resource is allowed.
latefinal
-
group
↔ Output<
String> -
The name of the instance group.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
name
↔ Output<
String> -
The name for this named port. The name must be 1-63 characters
long, and comply with RFC1035.
latefinal
-
port
↔ Output<
int> -
The port number, which can be a value between 1 and 65535.
latefinal
-
project
↔ Output<
String> -
The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
-
zone
↔ Output<
String> -
The zone of the instance group.
latefinal
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {InstanceGroupNamedPortState? state, CustomResourceOptions? options}) → InstanceGroupNamedPortCompute -
Gets an existing InstanceGroupNamedPortCompute resource's state with the given
nameandid.