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

com.pulumi.azure.compute.kotlin.ImageArgs.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.compute.kotlin

import com.pulumi.azure.compute.ImageArgs.builder
import com.pulumi.azure.compute.kotlin.inputs.ImageDataDiskArgs
import com.pulumi.azure.compute.kotlin.inputs.ImageDataDiskArgsBuilder
import com.pulumi.azure.compute.kotlin.inputs.ImageOsDiskArgs
import com.pulumi.azure.compute.kotlin.inputs.ImageOsDiskArgsBuilder
import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.applySuspend
import kotlin.Boolean
import kotlin.Pair
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import kotlin.jvm.JvmName

/**
 * Manages a custom virtual machine image that can be used to create virtual machines.
 * ## Example Usage
 * > **Note:** For a more complete example, see the `examples/image` directory within the GitHub Repository.
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = azure.compute.getVirtualMachine({
 *     name: "examplevm",
 *     resourceGroupName: "example-resources",
 * });
 * const exampleImage = new azure.compute.Image("example", {
 *     name: "exampleimage",
 *     location: example.then(example => example.location),
 *     resourceGroupName: example.then(example => example.name),
 *     sourceVirtualMachineId: example.then(example => example.id),
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.compute.get_virtual_machine(name="examplevm",
 *     resource_group_name="example-resources")
 * example_image = azure.compute.Image("example",
 *     name="exampleimage",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     source_virtual_machine_id=example.id)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = Azure.Compute.GetVirtualMachine.Invoke(new()
 *     {
 *         Name = "examplevm",
 *         ResourceGroupName = "example-resources",
 *     });
 *     var exampleImage = new Azure.Compute.Image("example", new()
 *     {
 *         Name = "exampleimage",
 *         Location = example.Apply(getVirtualMachineResult => getVirtualMachineResult.Location),
 *         ResourceGroupName = example.Apply(getVirtualMachineResult => getVirtualMachineResult.Name),
 *         SourceVirtualMachineId = example.Apply(getVirtualMachineResult => getVirtualMachineResult.Id),
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/compute"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := compute.LookupVirtualMachine(ctx, &compute.LookupVirtualMachineArgs{
 * 			Name:              "examplevm",
 * 			ResourceGroupName: "example-resources",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = compute.NewImage(ctx, "example", &compute.ImageArgs{
 * 			Name:                   pulumi.String("exampleimage"),
 * 			Location:               pulumi.String(example.Location),
 * 			ResourceGroupName:      pulumi.String(example.Name),
 * 			SourceVirtualMachineId: pulumi.String(example.Id),
 * 		})
 * 		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.azure.compute.ComputeFunctions;
 * import com.pulumi.azure.compute.inputs.GetVirtualMachineArgs;
 * import com.pulumi.azure.compute.Image;
 * import com.pulumi.azure.compute.ImageArgs;
 * 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 example = ComputeFunctions.getVirtualMachine(GetVirtualMachineArgs.builder()
 *             .name("examplevm")
 *             .resourceGroupName("example-resources")
 *             .build());
 *         var exampleImage = new Image("exampleImage", ImageArgs.builder()
 *             .name("exampleimage")
 *             .location(example.applyValue(getVirtualMachineResult -> getVirtualMachineResult.location()))
 *             .resourceGroupName(example.applyValue(getVirtualMachineResult -> getVirtualMachineResult.name()))
 *             .sourceVirtualMachineId(example.applyValue(getVirtualMachineResult -> getVirtualMachineResult.id()))
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   exampleImage:
 *     type: azure:compute:Image
 *     name: example
 *     properties:
 *       name: exampleimage
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       sourceVirtualMachineId: ${example.id}
 * variables:
 *   example:
 *     fn::invoke:
 *       Function: azure:compute:getVirtualMachine
 *       Arguments:
 *         name: examplevm
 *         resourceGroupName: example-resources
 * ```
 * 
 * ## Import
 * Images can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:compute/image:Image example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/images/image1
 * ```
 * @property dataDisks One or more `data_disk` blocks as defined below.
 * @property hyperVGeneration The HyperVGenerationType of the VirtualMachine created from the image as `V1`, `V2`. Defaults to `V1`. Changing this forces a new resource to be created.
 * > **Note:** `zone_resilient` can only be set to `true` if the image is stored in a region that supports availability zones.
 * @property location Specified the supported Azure location where the resource exists. Changing this forces a new resource to be created.
 * @property name Specifies the name of the image. Changing this forces a new resource to be created.
 * @property osDisk One or more `os_disk` blocks as defined below. Changing this forces a new resource to be created.
 * @property resourceGroupName The name of the resource group in which to create the image. Changing this forces a new resource to be created.
 * @property sourceVirtualMachineId The Virtual Machine ID from which to create the image.
 * @property tags A mapping of tags to assign to the resource.
 * @property zoneResilient Is zone resiliency enabled? Defaults to `false`. Changing this forces a new resource to be created.
 */
public data class ImageArgs(
    public val dataDisks: Output>? = null,
    public val hyperVGeneration: Output? = null,
    public val location: Output? = null,
    public val name: Output? = null,
    public val osDisk: Output? = null,
    public val resourceGroupName: Output? = null,
    public val sourceVirtualMachineId: Output? = null,
    public val tags: Output>? = null,
    public val zoneResilient: Output? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.azure.compute.ImageArgs =
        com.pulumi.azure.compute.ImageArgs.builder()
            .dataDisks(
                dataDisks?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.let({ args0 ->
                            args0.toJava()
                        })
                    })
                }),
            )
            .hyperVGeneration(hyperVGeneration?.applyValue({ args0 -> args0 }))
            .location(location?.applyValue({ args0 -> args0 }))
            .name(name?.applyValue({ args0 -> args0 }))
            .osDisk(osDisk?.applyValue({ args0 -> args0.let({ args0 -> args0.toJava() }) }))
            .resourceGroupName(resourceGroupName?.applyValue({ args0 -> args0 }))
            .sourceVirtualMachineId(sourceVirtualMachineId?.applyValue({ args0 -> args0 }))
            .tags(tags?.applyValue({ args0 -> args0.map({ args0 -> args0.key.to(args0.value) }).toMap() }))
            .zoneResilient(zoneResilient?.applyValue({ args0 -> args0 })).build()
}

/**
 * Builder for [ImageArgs].
 */
@PulumiTagMarker
public class ImageArgsBuilder internal constructor() {
    private var dataDisks: Output>? = null

    private var hyperVGeneration: Output? = null

    private var location: Output? = null

    private var name: Output? = null

    private var osDisk: Output? = null

    private var resourceGroupName: Output? = null

    private var sourceVirtualMachineId: Output? = null

    private var tags: Output>? = null

    private var zoneResilient: Output? = null

    /**
     * @param value One or more `data_disk` blocks as defined below.
     */
    @JvmName("semwcokcgyrlnvah")
    public suspend fun dataDisks(`value`: Output>) {
        this.dataDisks = value
    }

    @JvmName("jcmsndgwmudndfns")
    public suspend fun dataDisks(vararg values: Output) {
        this.dataDisks = Output.all(values.asList())
    }

    /**
     * @param values One or more `data_disk` blocks as defined below.
     */
    @JvmName("cywxeehdiemaxufb")
    public suspend fun dataDisks(values: List>) {
        this.dataDisks = Output.all(values)
    }

    /**
     * @param value The HyperVGenerationType of the VirtualMachine created from the image as `V1`, `V2`. Defaults to `V1`. Changing this forces a new resource to be created.
     * > **Note:** `zone_resilient` can only be set to `true` if the image is stored in a region that supports availability zones.
     */
    @JvmName("tkybmodktjheccft")
    public suspend fun hyperVGeneration(`value`: Output) {
        this.hyperVGeneration = value
    }

    /**
     * @param value Specified the supported Azure location where the resource exists. Changing this forces a new resource to be created.
     */
    @JvmName("vtbaamjemsnffdot")
    public suspend fun location(`value`: Output) {
        this.location = value
    }

    /**
     * @param value Specifies the name of the image. Changing this forces a new resource to be created.
     */
    @JvmName("twgcgwimsfopxbkf")
    public suspend fun name(`value`: Output) {
        this.name = value
    }

    /**
     * @param value One or more `os_disk` blocks as defined below. Changing this forces a new resource to be created.
     */
    @JvmName("bssxeitnetoijrmu")
    public suspend fun osDisk(`value`: Output) {
        this.osDisk = value
    }

    /**
     * @param value The name of the resource group in which to create the image. Changing this forces a new resource to be created.
     */
    @JvmName("ujenayoglugyepao")
    public suspend fun resourceGroupName(`value`: Output) {
        this.resourceGroupName = value
    }

    /**
     * @param value The Virtual Machine ID from which to create the image.
     */
    @JvmName("ymkdkrwjeckhankc")
    public suspend fun sourceVirtualMachineId(`value`: Output) {
        this.sourceVirtualMachineId = value
    }

    /**
     * @param value A mapping of tags to assign to the resource.
     */
    @JvmName("dfaspnkeigrbojyq")
    public suspend fun tags(`value`: Output>) {
        this.tags = value
    }

    /**
     * @param value Is zone resiliency enabled? Defaults to `false`. Changing this forces a new resource to be created.
     */
    @JvmName("lapgrbgkqocxjane")
    public suspend fun zoneResilient(`value`: Output) {
        this.zoneResilient = value
    }

    /**
     * @param value One or more `data_disk` blocks as defined below.
     */
    @JvmName("hbmjngreoquvhhic")
    public suspend fun dataDisks(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.dataDisks = mapped
    }

    /**
     * @param argument One or more `data_disk` blocks as defined below.
     */
    @JvmName("cavlwwsxkvglhsuv")
    public suspend fun dataDisks(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            ImageDataDiskArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.dataDisks = mapped
    }

    /**
     * @param argument One or more `data_disk` blocks as defined below.
     */
    @JvmName("jhpdknoyfelptitj")
    public suspend fun dataDisks(vararg argument: suspend ImageDataDiskArgsBuilder.() -> Unit) {
        val toBeMapped = argument.toList().map {
            ImageDataDiskArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.dataDisks = mapped
    }

    /**
     * @param argument One or more `data_disk` blocks as defined below.
     */
    @JvmName("jqfnluivptllymii")
    public suspend fun dataDisks(argument: suspend ImageDataDiskArgsBuilder.() -> Unit) {
        val toBeMapped = listOf(ImageDataDiskArgsBuilder().applySuspend { argument() }.build())
        val mapped = of(toBeMapped)
        this.dataDisks = mapped
    }

    /**
     * @param values One or more `data_disk` blocks as defined below.
     */
    @JvmName("qefvsvvllvfkjsie")
    public suspend fun dataDisks(vararg values: ImageDataDiskArgs) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.dataDisks = mapped
    }

    /**
     * @param value The HyperVGenerationType of the VirtualMachine created from the image as `V1`, `V2`. Defaults to `V1`. Changing this forces a new resource to be created.
     * > **Note:** `zone_resilient` can only be set to `true` if the image is stored in a region that supports availability zones.
     */
    @JvmName("tasrtiumdmldinhd")
    public suspend fun hyperVGeneration(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.hyperVGeneration = mapped
    }

    /**
     * @param value Specified the supported Azure location where the resource exists. Changing this forces a new resource to be created.
     */
    @JvmName("xfnfokhlxlromado")
    public suspend fun location(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.location = mapped
    }

    /**
     * @param value Specifies the name of the image. Changing this forces a new resource to be created.
     */
    @JvmName("cmviuxtljhfkgqdw")
    public suspend fun name(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.name = mapped
    }

    /**
     * @param value One or more `os_disk` blocks as defined below. Changing this forces a new resource to be created.
     */
    @JvmName("kcsuwkrgouuugthf")
    public suspend fun osDisk(`value`: ImageOsDiskArgs?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.osDisk = mapped
    }

    /**
     * @param argument One or more `os_disk` blocks as defined below. Changing this forces a new resource to be created.
     */
    @JvmName("spfwdctuwlvwukxk")
    public suspend fun osDisk(argument: suspend ImageOsDiskArgsBuilder.() -> Unit) {
        val toBeMapped = ImageOsDiskArgsBuilder().applySuspend { argument() }.build()
        val mapped = of(toBeMapped)
        this.osDisk = mapped
    }

    /**
     * @param value The name of the resource group in which to create the image. Changing this forces a new resource to be created.
     */
    @JvmName("syururdbmmagtmpm")
    public suspend fun resourceGroupName(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.resourceGroupName = mapped
    }

    /**
     * @param value The Virtual Machine ID from which to create the image.
     */
    @JvmName("herjawffpurpxwfd")
    public suspend fun sourceVirtualMachineId(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.sourceVirtualMachineId = mapped
    }

    /**
     * @param value A mapping of tags to assign to the resource.
     */
    @JvmName("guluckaqaysyvpfd")
    public suspend fun tags(`value`: Map?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.tags = mapped
    }

    /**
     * @param values A mapping of tags to assign to the resource.
     */
    @JvmName("efmrnravjuydmyhm")
    public fun tags(vararg values: Pair) {
        val toBeMapped = values.toMap()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.tags = mapped
    }

    /**
     * @param value Is zone resiliency enabled? Defaults to `false`. Changing this forces a new resource to be created.
     */
    @JvmName("stdqatiknimilppx")
    public suspend fun zoneResilient(`value`: Boolean?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.zoneResilient = mapped
    }

    internal fun build(): ImageArgs = ImageArgs(
        dataDisks = dataDisks,
        hyperVGeneration = hyperVGeneration,
        location = location,
        name = name,
        osDisk = osDisk,
        resourceGroupName = resourceGroupName,
        sourceVirtualMachineId = sourceVirtualMachineId,
        tags = tags,
        zoneResilient = zoneResilient,
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy