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

com.pulumi.gcp.compute.kotlin.InstanceSettings.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.InstanceSettingsMetadata
import com.pulumi.gcp.compute.kotlin.outputs.InstanceSettingsMetadata.Companion.toKotlin
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

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

    public var args: InstanceSettingsArgs = InstanceSettingsArgs()

    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 InstanceSettingsArgsBuilder.() -> Unit) {
        val builder = InstanceSettingsArgsBuilder()
        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(): InstanceSettings {
        val builtJavaResource = com.pulumi.gcp.compute.InstanceSettings(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return InstanceSettings(builtJavaResource)
    }
}

/**
 * Represents an Instance Settings resource. Instance settings are centralized configuration parameters that allow users to configure the default values for specific VM parameters that are normally set using GCE instance API methods.
 * To get more information about InstanceSettings, see:
 * * [API documentation](https://cloud.google.com/compute/docs/reference/rest/beta/instanceSettings)
 * * How-to Guides
 *     * [Update Instance Settings](https://cloud.google.com/compute/docs/metadata/setting-custom-metadata#set-custom-project-zonal-metadata)
 * ## Example Usage
 * ### Instance Settings Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const gceInstanceSettings = new gcp.compute.InstanceSettings("gce_instance_settings", {
 *     zone: "us-east7-b",
 *     metadata: {
 *         items: {
 *             foo: "baz",
 *         },
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * gce_instance_settings = gcp.compute.InstanceSettings("gce_instance_settings",
 *     zone="us-east7-b",
 *     metadata=gcp.compute.InstanceSettingsMetadataArgs(
 *         items={
 *             "foo": "baz",
 *         },
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var gceInstanceSettings = new Gcp.Compute.InstanceSettings("gce_instance_settings", new()
 *     {
 *         Zone = "us-east7-b",
 *         Metadata = new Gcp.Compute.Inputs.InstanceSettingsMetadataArgs
 *         {
 *             Items =
 *             {
 *                 { "foo", "baz" },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```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.NewInstanceSettings(ctx, "gce_instance_settings", &compute.InstanceSettingsArgs{
 * 			Zone: pulumi.String("us-east7-b"),
 * 			Metadata: &compute.InstanceSettingsMetadataArgs{
 * 				Items: pulumi.StringMap{
 * 					"foo": pulumi.String("baz"),
 * 				},
 * 			},
 * 		})
 * 		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.InstanceSettings;
 * import com.pulumi.gcp.compute.InstanceSettingsArgs;
 * import com.pulumi.gcp.compute.inputs.InstanceSettingsMetadataArgs;
 * 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 gceInstanceSettings = new InstanceSettings("gceInstanceSettings", InstanceSettingsArgs.builder()
 *             .zone("us-east7-b")
 *             .metadata(InstanceSettingsMetadataArgs.builder()
 *                 .items(Map.of("foo", "baz"))
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   gceInstanceSettings:
 *     type: gcp:compute:InstanceSettings
 *     name: gce_instance_settings
 *     properties:
 *       zone: us-east7-b
 *       metadata:
 *         items:
 *           foo: baz
 * ```
 * 
 * ## Import
 * InstanceSettings can be imported using any of these accepted formats:
 * * `projects/{{project}}/zones/{{zone}}/instanceSettings`
 * * `{{project}}/{{zone}}`
 * * `{{zone}}`
 * When using the `pulumi import` command, InstanceSettings can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:compute/instanceSettings:InstanceSettings default projects/{{project}}/zones/{{zone}}/instanceSettings
 * ```
 * ```sh
 * $ pulumi import gcp:compute/instanceSettings:InstanceSettings default {{project}}/{{zone}}
 * ```
 * ```sh
 * $ pulumi import gcp:compute/instanceSettings:InstanceSettings default {{zone}}
 * ```
 */
public class InstanceSettings internal constructor(
    override val javaResource: com.pulumi.gcp.compute.InstanceSettings,
) : KotlinCustomResource(javaResource, InstanceSettingsMapper) {
    /**
     * The fingerprint used for optimistic locking of this resource.  Used
     * internally during updates.
     */
    public val fingerprint: Output
        get() = javaResource.fingerprint().applyValue({ args0 -> args0 })

    /**
     * The metadata key/value pairs assigned to all the instances in the corresponding scope.
     * Structure is documented below.
     */
    public val metadata: Output?
        get() = javaResource.metadata().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    toKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * The ID of the project in which the resource belongs.
     * If it is not provided, the provider project is used.
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * A reference to the zone where the machine resides.
     * - - -
     */
    public val zone: Output
        get() = javaResource.zone().applyValue({ args0 -> args0 })
}

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy