gcp.compute.InstanceGroupMembership
Explore with Pulumi AI
Represents the Instance membership to the Instance Group.
NOTE You can use this resource instead of the
instances
field in thegcp.compute.InstanceGroup
, however it’s not recommended to use it alongside this field. It might cause inconsistencies, as they can end up competing over control.
NOTE This resource has been added to avoid a situation, where after Instance is recreated, it’s removed from Instance Group and it’s needed to perform
apply
twice. To avoid situations like this, please use this resource with the lifecyclereplace_triggered_by
method, with the passed Instance’s ID.
To get more information about InstanceGroupMembership, see:
Example Usage
Instance Group Membership
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const default_network = new gcp.compute.Network("default-network", {name: "network"});
const default_instance = new gcp.compute.Instance("default-instance", {
name: "instance",
machineType: "e2-medium",
bootDisk: {
initializeParams: {
image: "debian-cloud/debian-11",
},
},
networkInterfaces: [{
network: default_network.name,
}],
});
const default_instance_group = new gcp.compute.InstanceGroup("default-instance-group", {name: "instance-group"});
const default_ig_membership = new gcp.compute.InstanceGroupMembership("default-ig-membership", {
instance: default_instance.selfLink,
instanceGroup: default_instance_group.name,
});
import pulumi
import pulumi_gcp as gcp
default_network = gcp.compute.Network("default-network", name="network")
default_instance = gcp.compute.Instance("default-instance",
name="instance",
machine_type="e2-medium",
boot_disk={
"initialize_params": {
"image": "debian-cloud/debian-11",
},
},
network_interfaces=[{
"network": default_network.name,
}])
default_instance_group = gcp.compute.InstanceGroup("default-instance-group", name="instance-group")
default_ig_membership = gcp.compute.InstanceGroupMembership("default-ig-membership",
instance=default_instance.self_link,
instance_group=default_instance_group.name)
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := compute.NewNetwork(ctx, "default-network", &compute.NetworkArgs{
Name: pulumi.String("network"),
})
if err != nil {
return err
}
_, err = compute.NewInstance(ctx, "default-instance", &compute.InstanceArgs{
Name: pulumi.String("instance"),
MachineType: pulumi.String("e2-medium"),
BootDisk: &compute.InstanceBootDiskArgs{
InitializeParams: &compute.InstanceBootDiskInitializeParamsArgs{
Image: pulumi.String("debian-cloud/debian-11"),
},
},
NetworkInterfaces: compute.InstanceNetworkInterfaceArray{
&compute.InstanceNetworkInterfaceArgs{
Network: default_network.Name,
},
},
})
if err != nil {
return err
}
_, err = compute.NewInstanceGroup(ctx, "default-instance-group", &compute.InstanceGroupArgs{
Name: pulumi.String("instance-group"),
})
if err != nil {
return err
}
_, err = compute.NewInstanceGroupMembership(ctx, "default-ig-membership", &compute.InstanceGroupMembershipArgs{
Instance: default_instance.SelfLink,
InstanceGroup: default_instance_group.Name,
})
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 default_network = new Gcp.Compute.Network("default-network", new()
{
Name = "network",
});
var default_instance = new Gcp.Compute.Instance("default-instance", new()
{
Name = "instance",
MachineType = "e2-medium",
BootDisk = new Gcp.Compute.Inputs.InstanceBootDiskArgs
{
InitializeParams = new Gcp.Compute.Inputs.InstanceBootDiskInitializeParamsArgs
{
Image = "debian-cloud/debian-11",
},
},
NetworkInterfaces = new[]
{
new Gcp.Compute.Inputs.InstanceNetworkInterfaceArgs
{
Network = default_network.Name,
},
},
});
var default_instance_group = new Gcp.Compute.InstanceGroup("default-instance-group", new()
{
Name = "instance-group",
});
var default_ig_membership = new Gcp.Compute.InstanceGroupMembership("default-ig-membership", new()
{
Instance = default_instance.SelfLink,
InstanceGroup = default_instance_group.Name,
});
});
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.Instance;
import com.pulumi.gcp.compute.InstanceArgs;
import com.pulumi.gcp.compute.inputs.InstanceBootDiskArgs;
import com.pulumi.gcp.compute.inputs.InstanceBootDiskInitializeParamsArgs;
import com.pulumi.gcp.compute.inputs.InstanceNetworkInterfaceArgs;
import com.pulumi.gcp.compute.InstanceGroup;
import com.pulumi.gcp.compute.InstanceGroupArgs;
import com.pulumi.gcp.compute.InstanceGroupMembership;
import com.pulumi.gcp.compute.InstanceGroupMembershipArgs;
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 default_network = new Network("default-network", NetworkArgs.builder()
.name("network")
.build());
var default_instance = new Instance("default-instance", InstanceArgs.builder()
.name("instance")
.machineType("e2-medium")
.bootDisk(InstanceBootDiskArgs.builder()
.initializeParams(InstanceBootDiskInitializeParamsArgs.builder()
.image("debian-cloud/debian-11")
.build())
.build())
.networkInterfaces(InstanceNetworkInterfaceArgs.builder()
.network(default_network.name())
.build())
.build());
var default_instance_group = new InstanceGroup("default-instance-group", InstanceGroupArgs.builder()
.name("instance-group")
.build());
var default_ig_membership = new InstanceGroupMembership("default-ig-membership", InstanceGroupMembershipArgs.builder()
.instance(default_instance.selfLink())
.instanceGroup(default_instance_group.name())
.build());
}
}
resources:
default-network:
type: gcp:compute:Network
properties:
name: network
default-instance:
type: gcp:compute:Instance
properties:
name: instance
machineType: e2-medium
bootDisk:
initializeParams:
image: debian-cloud/debian-11
networkInterfaces:
- network: ${["default-network"].name}
default-instance-group:
type: gcp:compute:InstanceGroup
properties:
name: instance-group
default-ig-membership:
type: gcp:compute:InstanceGroupMembership
properties:
instance: ${["default-instance"].selfLink}
instanceGroup: ${["default-instance-group"].name}
Create InstanceGroupMembership Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new InstanceGroupMembership(name: string, args: InstanceGroupMembershipArgs, opts?: CustomResourceOptions);
@overload
def InstanceGroupMembership(resource_name: str,
args: InstanceGroupMembershipArgs,
opts: Optional[ResourceOptions] = None)
@overload
def InstanceGroupMembership(resource_name: str,
opts: Optional[ResourceOptions] = None,
instance: Optional[str] = None,
instance_group: Optional[str] = None,
project: Optional[str] = None,
zone: Optional[str] = None)
func NewInstanceGroupMembership(ctx *Context, name string, args InstanceGroupMembershipArgs, opts ...ResourceOption) (*InstanceGroupMembership, error)
public InstanceGroupMembership(string name, InstanceGroupMembershipArgs args, CustomResourceOptions? opts = null)
public InstanceGroupMembership(String name, InstanceGroupMembershipArgs args)
public InstanceGroupMembership(String name, InstanceGroupMembershipArgs args, CustomResourceOptions options)
type: gcp:compute:InstanceGroupMembership
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 InstanceGroupMembershipArgs
- 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 InstanceGroupMembershipArgs
- 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 InstanceGroupMembershipArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args InstanceGroupMembershipArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args InstanceGroupMembershipArgs
- 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 instanceGroupMembershipResource = new Gcp.Compute.InstanceGroupMembership("instanceGroupMembershipResource", new()
{
Instance = "string",
InstanceGroup = "string",
Project = "string",
Zone = "string",
});
example, err := compute.NewInstanceGroupMembership(ctx, "instanceGroupMembershipResource", &compute.InstanceGroupMembershipArgs{
Instance: pulumi.String("string"),
InstanceGroup: pulumi.String("string"),
Project: pulumi.String("string"),
Zone: pulumi.String("string"),
})
var instanceGroupMembershipResource = new InstanceGroupMembership("instanceGroupMembershipResource", InstanceGroupMembershipArgs.builder()
.instance("string")
.instanceGroup("string")
.project("string")
.zone("string")
.build());
instance_group_membership_resource = gcp.compute.InstanceGroupMembership("instanceGroupMembershipResource",
instance="string",
instance_group="string",
project="string",
zone="string")
const instanceGroupMembershipResource = new gcp.compute.InstanceGroupMembership("instanceGroupMembershipResource", {
instance: "string",
instanceGroup: "string",
project: "string",
zone: "string",
});
type: gcp:compute:InstanceGroupMembership
properties:
instance: string
instanceGroup: string
project: string
zone: string
InstanceGroupMembership 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 InstanceGroupMembership resource accepts the following input properties:
- Instance string
- An instance being added to the InstanceGroup
- Instance
Group string - Represents an Instance Group resource name that the instance belongs to.
- Project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Zone string
- A reference to the zone where the instance group resides.
- Instance string
- An instance being added to the InstanceGroup
- Instance
Group string - Represents an Instance Group resource name that the instance belongs to.
- Project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Zone string
- A reference to the zone where the instance group resides.
- instance String
- An instance being added to the InstanceGroup
- instance
Group String - Represents an Instance Group resource name that the instance belongs to.
- project String
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- zone String
- A reference to the zone where the instance group resides.
- instance string
- An instance being added to the InstanceGroup
- instance
Group string - Represents an Instance Group resource name that the instance belongs to.
- project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- zone string
- A reference to the zone where the instance group resides.
- instance str
- An instance being added to the InstanceGroup
- instance_
group str - Represents an Instance Group resource name that the instance belongs to.
- project str
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- zone str
- A reference to the zone where the instance group resides.
- instance String
- An instance being added to the InstanceGroup
- instance
Group String - Represents an Instance Group resource name that the instance belongs to.
- project String
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- zone String
- A reference to the zone where the instance group resides.
Outputs
All input properties are implicitly available as output properties. Additionally, the InstanceGroupMembership 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 InstanceGroupMembership Resource
Get an existing InstanceGroupMembership 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?: InstanceGroupMembershipState, opts?: CustomResourceOptions): InstanceGroupMembership
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
instance: Optional[str] = None,
instance_group: Optional[str] = None,
project: Optional[str] = None,
zone: Optional[str] = None) -> InstanceGroupMembership
func GetInstanceGroupMembership(ctx *Context, name string, id IDInput, state *InstanceGroupMembershipState, opts ...ResourceOption) (*InstanceGroupMembership, error)
public static InstanceGroupMembership Get(string name, Input<string> id, InstanceGroupMembershipState? state, CustomResourceOptions? opts = null)
public static InstanceGroupMembership get(String name, Output<String> id, InstanceGroupMembershipState 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.
- Instance string
- An instance being added to the InstanceGroup
- Instance
Group string - Represents an Instance Group resource name that the instance belongs to.
- Project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Zone string
- A reference to the zone where the instance group resides.
- Instance string
- An instance being added to the InstanceGroup
- Instance
Group string - Represents an Instance Group resource name that the instance belongs to.
- Project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Zone string
- A reference to the zone where the instance group resides.
- instance String
- An instance being added to the InstanceGroup
- instance
Group String - Represents an Instance Group resource name that the instance belongs to.
- project String
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- zone String
- A reference to the zone where the instance group resides.
- instance string
- An instance being added to the InstanceGroup
- instance
Group string - Represents an Instance Group resource name that the instance belongs to.
- project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- zone string
- A reference to the zone where the instance group resides.
- instance str
- An instance being added to the InstanceGroup
- instance_
group str - Represents an Instance Group resource name that the instance belongs to.
- project str
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- zone str
- A reference to the zone where the instance group resides.
- instance String
- An instance being added to the InstanceGroup
- instance
Group String - Represents an Instance Group resource name that the instance belongs to.
- project String
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- zone String
- A reference to the zone where the instance group resides.
Import
InstanceGroupMembership can be imported using any of these accepted formats:
projects/{{project}}/zones/{{zone}}/instanceGroups/{{instance_group}}/{{instance}}
{{project}}/{{zone}}/{{instance_group}}/{{instance}}
{{zone}}/{{instance_group}}/{{instance}}
{{instance_group}}/{{instance}}
When using the pulumi import
command, InstanceGroupMembership can be imported using one of the formats above. For example:
$ pulumi import gcp:compute/instanceGroupMembership:InstanceGroupMembership default projects/{{project}}/zones/{{zone}}/instanceGroups/{{instance_group}}/{{instance}}
$ pulumi import gcp:compute/instanceGroupMembership:InstanceGroupMembership default {{project}}/{{zone}}/{{instance_group}}/{{instance}}
$ pulumi import gcp:compute/instanceGroupMembership:InstanceGroupMembership default {{zone}}/{{instance_group}}/{{instance}}
$ pulumi import gcp:compute/instanceGroupMembership:InstanceGroupMembership default {{instance_group}}/{{instance}}
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.