All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.gcp.compute.kotlin.InstanceFromMachineImage.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 8.10.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.compute.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageAdvancedMachineFeatures
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageAttachedDisk
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageBootDisk
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageConfidentialInstanceConfig
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageGuestAccelerator
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageNetworkInterface
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageNetworkPerformanceConfig
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageParams
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageReservationAffinity
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageScheduling
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageScratchDisk
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageServiceAccount
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageShieldedInstanceConfig
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageAdvancedMachineFeatures.Companion.toKotlin as instanceFromMachineImageAdvancedMachineFeaturesToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageAttachedDisk.Companion.toKotlin as instanceFromMachineImageAttachedDiskToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageBootDisk.Companion.toKotlin as instanceFromMachineImageBootDiskToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageConfidentialInstanceConfig.Companion.toKotlin as instanceFromMachineImageConfidentialInstanceConfigToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageGuestAccelerator.Companion.toKotlin as instanceFromMachineImageGuestAcceleratorToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageNetworkInterface.Companion.toKotlin as instanceFromMachineImageNetworkInterfaceToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageNetworkPerformanceConfig.Companion.toKotlin as instanceFromMachineImageNetworkPerformanceConfigToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageParams.Companion.toKotlin as instanceFromMachineImageParamsToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageReservationAffinity.Companion.toKotlin as instanceFromMachineImageReservationAffinityToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageScheduling.Companion.toKotlin as instanceFromMachineImageSchedulingToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageScratchDisk.Companion.toKotlin as instanceFromMachineImageScratchDiskToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageServiceAccount.Companion.toKotlin as instanceFromMachineImageServiceAccountToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.InstanceFromMachineImageShieldedInstanceConfig.Companion.toKotlin as instanceFromMachineImageShieldedInstanceConfigToKotlin

/**
 * Builder for [InstanceFromMachineImage].
 */
@PulumiTagMarker
public class InstanceFromMachineImageResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: InstanceFromMachineImageArgs = InstanceFromMachineImageArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend InstanceFromMachineImageArgsBuilder.() -> Unit) {
        val builder = InstanceFromMachineImageArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): InstanceFromMachineImage {
        val builtJavaResource = com.pulumi.gcp.compute.InstanceFromMachineImage(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return InstanceFromMachineImage(builtJavaResource)
    }
}

/**
 * Manages a VM instance resource within GCE. For more information see
 * [the official documentation](https://cloud.google.com/compute/docs/instances)
 * and
 * [API](https://cloud.google.com/compute/docs/reference/latest/instances).
 * This resource is specifically to create a compute instance from a given
 * `source_machine_image`. To create an instance without a machine image, use the
 * `gcp.compute.Instance` resource.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const tpl = new gcp.compute.InstanceFromMachineImage("tpl", {
 *     name: "instance-from-machine-image",
 *     zone: "us-central1-a",
 *     sourceMachineImage: "projects/PROJECT-ID/global/machineImages/NAME",
 *     canIpForward: false,
 *     labels: {
 *         my_key: "my_value",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * tpl = gcp.compute.InstanceFromMachineImage("tpl",
 *     name="instance-from-machine-image",
 *     zone="us-central1-a",
 *     source_machine_image="projects/PROJECT-ID/global/machineImages/NAME",
 *     can_ip_forward=False,
 *     labels={
 *         "my_key": "my_value",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var tpl = new Gcp.Compute.InstanceFromMachineImage("tpl", new()
 *     {
 *         Name = "instance-from-machine-image",
 *         Zone = "us-central1-a",
 *         SourceMachineImage = "projects/PROJECT-ID/global/machineImages/NAME",
 *         CanIpForward = false,
 *         Labels =
 *         {
 *             { "my_key", "my_value" },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := compute.NewInstanceFromMachineImage(ctx, "tpl", &compute.InstanceFromMachineImageArgs{
 * 			Name:               pulumi.String("instance-from-machine-image"),
 * 			Zone:               pulumi.String("us-central1-a"),
 * 			SourceMachineImage: pulumi.String("projects/PROJECT-ID/global/machineImages/NAME"),
 * 			CanIpForward:       pulumi.Bool(false),
 * 			Labels: pulumi.StringMap{
 * 				"my_key": pulumi.String("my_value"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.compute.InstanceFromMachineImage;
 * import com.pulumi.gcp.compute.InstanceFromMachineImageArgs;
 * 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 tpl = new InstanceFromMachineImage("tpl", InstanceFromMachineImageArgs.builder()
 *             .name("instance-from-machine-image")
 *             .zone("us-central1-a")
 *             .sourceMachineImage("projects/PROJECT-ID/global/machineImages/NAME")
 *             .canIpForward(false)
 *             .labels(Map.of("my_key", "my_value"))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   tpl:
 *     type: gcp:compute:InstanceFromMachineImage
 *     properties:
 *       name: instance-from-machine-image
 *       zone: us-central1-a
 *       sourceMachineImage: projects/PROJECT-ID/global/machineImages/NAME
 *       canIpForward: false
 *       labels:
 *         my_key: my_value
 * ```
 * 
 */
public class InstanceFromMachineImage internal constructor(
    override val javaResource: com.pulumi.gcp.compute.InstanceFromMachineImage,
) : KotlinCustomResource(javaResource, InstanceFromMachineImageMapper) {
    /**
     * Controls for advanced machine-related behavior features.
     */
    public val advancedMachineFeatures: Output
        get() = javaResource.advancedMachineFeatures().applyValue({ args0 ->
            args0.let({ args0 ->
                instanceFromMachineImageAdvancedMachineFeaturesToKotlin(args0)
            })
        })

    public val allowStoppingForUpdate: Output
        get() = javaResource.allowStoppingForUpdate().applyValue({ args0 -> args0 })

    /**
     * List of disks attached to the instance
     */
    public val attachedDisks: Output>
        get() = javaResource.attachedDisks().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> instanceFromMachineImageAttachedDiskToKotlin(args0) })
            })
        })

    /**
     * The boot disk for the instance.
     */
    public val bootDisks: Output>
        get() = javaResource.bootDisks().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    instanceFromMachineImageBootDiskToKotlin(args0)
                })
            })
        })

    /**
     * Whether sending and receiving of packets with non-matching source or destination IPs is allowed.
     */
    public val canIpForward: Output
        get() = javaResource.canIpForward().applyValue({ args0 -> args0 })

    /**
     * The Confidential VM config being used by the instance. on_host_maintenance has to be set to TERMINATE or this will fail
     * to create.
     */
    public val confidentialInstanceConfig: Output
        get() = javaResource.confidentialInstanceConfig().applyValue({ args0 ->
            args0.let({ args0 ->
                instanceFromMachineImageConfidentialInstanceConfigToKotlin(args0)
            })
        })

    /**
     * The CPU platform used by this instance.
     */
    public val cpuPlatform: Output
        get() = javaResource.cpuPlatform().applyValue({ args0 -> args0 })

    /**
     * Current status of the instance. This could be one of the following values: PROVISIONING, STAGING, RUNNING, STOPPING,
     * SUSPENDING, SUSPENDED, REPAIRING, and TERMINATED. For more information about the status of the instance, see [Instance
   * life cycle](https://cloud.google.com/compute/docs/instances/instance-life-cycle).
     */
    public val currentStatus: Output
        get() = javaResource.currentStatus().applyValue({ args0 -> args0 })

    /**
     * Whether deletion protection is enabled on this instance.
     */
    public val deletionProtection: Output
        get() = javaResource.deletionProtection().applyValue({ args0 -> args0 })

    /**
     * A brief description of the resource.
     */
    public val description: Output
        get() = javaResource.description().applyValue({ args0 -> args0 })

    /**
     * Desired status of the instance. Either "RUNNING" or "TERMINATED".
     */
    public val desiredStatus: Output
        get() = javaResource.desiredStatus().applyValue({ args0 -> args0 })

    public val effectiveLabels: Output>
        get() = javaResource.effectiveLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * Whether the instance has virtual displays enabled.
     */
    public val enableDisplay: Output
        get() = javaResource.enableDisplay().applyValue({ args0 -> args0 })

    /**
     * List of the type and count of accelerator cards attached to the instance.
     */
    public val guestAccelerators: Output>
        get() = javaResource.guestAccelerators().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> instanceFromMachineImageGuestAcceleratorToKotlin(args0) })
            })
        })

    /**
     * A custom hostname for the instance. Must be a fully qualified DNS name and RFC-1035-valid. Valid format is a series of
     * labels 1-63 characters long matching the regular expression a-z, concatenated with periods. The entire hostname must not
     * exceed 253 characters. Changing this forces a new resource to be created.
     */
    public val hostname: Output
        get() = javaResource.hostname().applyValue({ args0 -> args0 })

    /**
     * The server-assigned unique identifier of this instance.
     */
    public val instanceId: Output
        get() = javaResource.instanceId().applyValue({ args0 -> args0 })

    /**
     * The unique fingerprint of the labels.
     */
    public val labelFingerprint: Output
        get() = javaResource.labelFingerprint().applyValue({ args0 -> args0 })

    /**
     * A set of key/value label pairs assigned to the instance. **Note**: This field is non-authoritative, and will only manage
     * the labels present in your configuration. Please refer to the field 'effective_labels' for all of the labels present on
     * the resource.
     */
    public val labels: Output>
        get() = javaResource.labels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * The machine type to create.
     */
    public val machineType: Output
        get() = javaResource.machineType().applyValue({ args0 -> args0 })

    /**
     * Metadata key/value pairs made available within the instance.
     */
    public val metadata: Output>
        get() = javaResource.metadata().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * The unique fingerprint of the metadata.
     */
    public val metadataFingerprint: Output
        get() = javaResource.metadataFingerprint().applyValue({ args0 -> args0 })

    /**
     * Metadata startup scripts made available within the instance.
     */
    public val metadataStartupScript: Output
        get() = javaResource.metadataStartupScript().applyValue({ args0 -> args0 })

    /**
     * The minimum CPU platform specified for the VM instance.
     */
    public val minCpuPlatform: Output
        get() = javaResource.minCpuPlatform().applyValue({ args0 -> args0 })

    /**
     * A unique name for the resource, required by GCE.
     * Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The networks attached to the instance.
     */
    public val networkInterfaces: Output>
        get() = javaResource.networkInterfaces().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> instanceFromMachineImageNetworkInterfaceToKotlin(args0) })
            })
        })

    /**
     * Configures network performance settings for the instance. If not specified, the instance will be created with its
     * default network performance configuration.
     */
    public val networkPerformanceConfig: Output
        get() = javaResource.networkPerformanceConfig().applyValue({ args0 ->
            args0.let({ args0 ->
                instanceFromMachineImageNetworkPerformanceConfigToKotlin(args0)
            })
        })

    /**
     * Stores additional params passed with the request, but not persisted as part of resource payload.
     */
    public val params: Output
        get() = javaResource.params().applyValue({ args0 ->
            args0.let({ args0 ->
                instanceFromMachineImageParamsToKotlin(args0)
            })
        })

    /**
     * The ID of the project in which the resource belongs. If self_link is provided, this value is ignored. If neither
     * self_link nor project are provided, the provider project is used.
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * The combination of labels configured directly on the resource and default labels configured on the provider.
     */
    public val pulumiLabels: Output>
        get() = javaResource.pulumiLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * Specifies the reservations that this instance can consume from.
     */
    public val reservationAffinity: Output
        get() = javaResource.reservationAffinity().applyValue({ args0 ->
            args0.let({ args0 ->
                instanceFromMachineImageReservationAffinityToKotlin(args0)
            })
        })

    /**
     * A list of self_links of resource policies to attach to the instance. Currently a max of 1 resource policy is supported.
     */
    public val resourcePolicies: Output
        get() = javaResource.resourcePolicies().applyValue({ args0 -> args0 })

    /**
     * The scheduling strategy being used by the instance.
     */
    public val scheduling: Output
        get() = javaResource.scheduling().applyValue({ args0 ->
            args0.let({ args0 ->
                instanceFromMachineImageSchedulingToKotlin(args0)
            })
        })

    /**
     * The scratch disks attached to the instance.
     */
    public val scratchDisks: Output>
        get() = javaResource.scratchDisks().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    instanceFromMachineImageScratchDiskToKotlin(args0)
                })
            })
        })

    /**
     * The URI of the created resource.
     */
    public val selfLink: Output
        get() = javaResource.selfLink().applyValue({ args0 -> args0 })

    /**
     * The service account to attach to the instance.
     */
    public val serviceAccount: Output
        get() = javaResource.serviceAccount().applyValue({ args0 ->
            args0.let({ args0 ->
                instanceFromMachineImageServiceAccountToKotlin(args0)
            })
        })

    /**
     * The shielded vm config being used by the instance.
     */
    public val shieldedInstanceConfig: Output
        get() = javaResource.shieldedInstanceConfig().applyValue({ args0 ->
            args0.let({ args0 ->
                instanceFromMachineImageShieldedInstanceConfigToKotlin(args0)
            })
        })

    /**
     * Name or self link of a machine
     * image to create the instance based on.
     * - - -
     */
    public val sourceMachineImage: Output
        get() = javaResource.sourceMachineImage().applyValue({ args0 -> args0 })

    /**
     * The list of tags attached to the instance.
     */
    public val tags: Output>
        get() = javaResource.tags().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * The unique fingerprint of the tags.
     */
    public val tagsFingerprint: Output
        get() = javaResource.tagsFingerprint().applyValue({ args0 -> args0 })

    /**
     * The zone that the machine should be created in. If not
     * set, the provider zone is used.
     * In addition to these, most* arguments from `gcp.compute.Instance` are supported
     * as a way to override the properties in the machine image. All exported attributes
     * from `gcp.compute.Instance` are likewise exported here.
     * > **Warning:** *Due to API limitations, disk overrides are currently disabled. This includes the "boot_disk", "attached_disk", and "scratch_disk" fields.
     */
    public val zone: Output
        get() = javaResource.zone().applyValue({ args0 -> args0 })
}

public object InstanceFromMachineImageMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.compute.InstanceFromMachineImage::class == javaResource::class

    override fun map(javaResource: Resource): InstanceFromMachineImage =
        InstanceFromMachineImage(javaResource as com.pulumi.gcp.compute.InstanceFromMachineImage)
}

/**
 * @see [InstanceFromMachineImage].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [InstanceFromMachineImage].
 */
public suspend fun instanceFromMachineImage(
    name: String,
    block: suspend InstanceFromMachineImageResourceBuilder.() -> Unit,
): InstanceFromMachineImage {
    val builder = InstanceFromMachineImageResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [InstanceFromMachineImage].
 * @param name The _unique_ name of the resulting resource.
 */
public fun instanceFromMachineImage(name: String): InstanceFromMachineImage {
    val builder = InstanceFromMachineImageResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy