TargetInstance

class TargetInstance : KotlinCustomResource

Represents a TargetInstance resource which defines an endpoint instance that terminates traffic of certain protocols. In particular, they are used in Protocol Forwarding, where forwarding rules can send packets to a non-NAT'ed target instance. Each target instance contains a single virtual machine instance that receives and handles traffic from the corresponding forwarding rules. To get more information about TargetInstance, see:

Example Usage

Target Instance Basic

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.ComputeFunctions;
import com.pulumi.gcp.compute.inputs.GetImageArgs;
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.TargetInstance;
import com.pulumi.gcp.compute.TargetInstanceArgs;
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) {
final var vmimage = ComputeFunctions.getImage(GetImageArgs.builder()
.family("debian-11")
.project("debian-cloud")
.build());
var target_vm = new Instance("target-vm", InstanceArgs.builder()
.machineType("e2-medium")
.zone("us-central1-a")
.bootDisk(InstanceBootDiskArgs.builder()
.initializeParams(InstanceBootDiskInitializeParamsArgs.builder()
.image(vmimage.applyValue(getImageResult -> getImageResult.selfLink()))
.build())
.build())
.networkInterfaces(InstanceNetworkInterfaceArgs.builder()
.network("default")
.build())
.build());
var default_ = new TargetInstance("default", TargetInstanceArgs.builder()
.instance(target_vm.id())
.build());
}
}

Target Instance Custom Network

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.ComputeFunctions;
import com.pulumi.gcp.compute.inputs.GetNetworkArgs;
import com.pulumi.gcp.compute.inputs.GetImageArgs;
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.TargetInstance;
import com.pulumi.gcp.compute.TargetInstanceArgs;
import com.pulumi.resources.CustomResourceOptions;
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) {
final var target-vmNetwork = ComputeFunctions.getNetwork(GetNetworkArgs.builder()
.name("default")
.build());
final var vmimage = ComputeFunctions.getImage(GetImageArgs.builder()
.family("debian-10")
.project("debian-cloud")
.build());
var target_vmInstance = new Instance("target-vmInstance", InstanceArgs.builder()
.machineType("e2-medium")
.zone("us-central1-a")
.bootDisk(InstanceBootDiskArgs.builder()
.initializeParams(InstanceBootDiskInitializeParamsArgs.builder()
.image(vmimage.applyValue(getImageResult -> getImageResult.selfLink()))
.build())
.build())
.networkInterfaces(InstanceNetworkInterfaceArgs.builder()
.network("default")
.build())
.build(), CustomResourceOptions.builder()
.provider(google_beta)
.build());
var customNetwork = new TargetInstance("customNetwork", TargetInstanceArgs.builder()
.instance(target_vmInstance.id())
.network(target_vmNetwork.selfLink())
.build(), CustomResourceOptions.builder()
.provider(google_beta)
.build());
}
}

Import

TargetInstance can be imported using any of these accepted formats

$ pulumi import gcp:compute/targetInstance:TargetInstance default projects/{{project}}/zones/{{zone}}/targetInstances/{{name}}
$ pulumi import gcp:compute/targetInstance:TargetInstance default {{project}}/{{zone}}/{{name}}
$ pulumi import gcp:compute/targetInstance:TargetInstance default {{zone}}/{{name}}
$ pulumi import gcp:compute/targetInstance:TargetInstance default {{name}}

Properties

Link copied to clipboard

Creation timestamp in RFC3339 text format.

Link copied to clipboard
val description: Output<String>?

An optional description of this resource.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val instance: Output<String>

The Compute instance VM handling traffic for this target instance. Accepts the instance self-link, relative path (e.g. projects/project/zones/zone/instances/instance) or name. If name is given, the zone will default to the given zone or the provider-default zone and the project will default to the provider-level project.

Link copied to clipboard
val name: Output<String>

Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression a-z? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.

Link copied to clipboard
val natPolicy: Output<String>?

NAT option controlling how IPs are NAT'ed to the instance. Currently only NO_NAT (default value) is supported. Default value is NO_NAT. Possible values are: NO_NAT.

Link copied to clipboard
val network: Output<String>?

The URL of the network this target instance uses to forward traffic. If not specified, the traffic will be forwarded to the network that the default network interface belongs to.

Link copied to clipboard
val project: Output<String>

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val securityPolicy: Output<String>?

The resource URL for the security policy associated with this target instance.

Link copied to clipboard
val selfLink: Output<String>

The URI of the created resource.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val zone: Output<String>

URL of the zone where the target instance resides.