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

com.pulumi.gcp.compute.kotlin.Reservation.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.12.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.ReservationShareSettings
import com.pulumi.gcp.compute.kotlin.outputs.ReservationSpecificReservation
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 com.pulumi.gcp.compute.kotlin.outputs.ReservationShareSettings.Companion.toKotlin as reservationShareSettingsToKotlin
import com.pulumi.gcp.compute.kotlin.outputs.ReservationSpecificReservation.Companion.toKotlin as reservationSpecificReservationToKotlin

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

    public var args: ReservationArgs = ReservationArgs()

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

/**
 * Represents a reservation resource. A reservation ensures that capacity is
 * held in a specific zone even if the reserved VMs are not running.
 * Reservations apply only to Compute Engine, Cloud Dataproc, and Google
 * Kubernetes Engine VM usage.Reservations do not apply to `f1-micro` or
 * `g1-small` machine types, preemptible VMs, sole tenant nodes, or other
 * services not listed above
 * like Cloud SQL and Dataflow.
 * To get more information about Reservation, see:
 * * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/reservations)
 * * How-to Guides
 *     * [Reserving zonal resources](https://cloud.google.com/compute/docs/instances/reserving-zonal-resources)
 * ## Example Usage
 * ### Reservation Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const gceReservation = new gcp.compute.Reservation("gce_reservation", {
 *     name: "gce-reservation",
 *     zone: "us-central1-a",
 *     specificReservation: {
 *         count: 1,
 *         instanceProperties: {
 *             minCpuPlatform: "Intel Cascade Lake",
 *             machineType: "n2-standard-2",
 *         },
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * gce_reservation = gcp.compute.Reservation("gce_reservation",
 *     name="gce-reservation",
 *     zone="us-central1-a",
 *     specific_reservation=gcp.compute.ReservationSpecificReservationArgs(
 *         count=1,
 *         instance_properties=gcp.compute.ReservationSpecificReservationInstancePropertiesArgs(
 *             min_cpu_platform="Intel Cascade Lake",
 *             machine_type="n2-standard-2",
 *         ),
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var gceReservation = new Gcp.Compute.Reservation("gce_reservation", new()
 *     {
 *         Name = "gce-reservation",
 *         Zone = "us-central1-a",
 *         SpecificReservation = new Gcp.Compute.Inputs.ReservationSpecificReservationArgs
 *         {
 *             Count = 1,
 *             InstanceProperties = new Gcp.Compute.Inputs.ReservationSpecificReservationInstancePropertiesArgs
 *             {
 *                 MinCpuPlatform = "Intel Cascade Lake",
 *                 MachineType = "n2-standard-2",
 *             },
 *         },
 *     });
 * });
 * ```
 * ```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.NewReservation(ctx, "gce_reservation", &compute.ReservationArgs{
 * 			Name: pulumi.String("gce-reservation"),
 * 			Zone: pulumi.String("us-central1-a"),
 * 			SpecificReservation: &compute.ReservationSpecificReservationArgs{
 * 				Count: pulumi.Int(1),
 * 				InstanceProperties: &compute.ReservationSpecificReservationInstancePropertiesArgs{
 * 					MinCpuPlatform: pulumi.String("Intel Cascade Lake"),
 * 					MachineType:    pulumi.String("n2-standard-2"),
 * 				},
 * 			},
 * 		})
 * 		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.Reservation;
 * import com.pulumi.gcp.compute.ReservationArgs;
 * import com.pulumi.gcp.compute.inputs.ReservationSpecificReservationArgs;
 * import com.pulumi.gcp.compute.inputs.ReservationSpecificReservationInstancePropertiesArgs;
 * 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 gceReservation = new Reservation("gceReservation", ReservationArgs.builder()
 *             .name("gce-reservation")
 *             .zone("us-central1-a")
 *             .specificReservation(ReservationSpecificReservationArgs.builder()
 *                 .count(1)
 *                 .instanceProperties(ReservationSpecificReservationInstancePropertiesArgs.builder()
 *                     .minCpuPlatform("Intel Cascade Lake")
 *                     .machineType("n2-standard-2")
 *                     .build())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   gceReservation:
 *     type: gcp:compute:Reservation
 *     name: gce_reservation
 *     properties:
 *       name: gce-reservation
 *       zone: us-central1-a
 *       specificReservation:
 *         count: 1
 *         instanceProperties:
 *           minCpuPlatform: Intel Cascade Lake
 *           machineType: n2-standard-2
 * ```
 * 
 * ## Import
 * Reservation can be imported using any of these accepted formats:
 * * `projects/{{project}}/zones/{{zone}}/reservations/{{name}}`
 * * `{{project}}/{{zone}}/{{name}}`
 * * `{{zone}}/{{name}}`
 * * `{{name}}`
 * When using the `pulumi import` command, Reservation can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:compute/reservation:Reservation default projects/{{project}}/zones/{{zone}}/reservations/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:compute/reservation:Reservation default {{project}}/{{zone}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:compute/reservation:Reservation default {{zone}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:compute/reservation:Reservation default {{name}}
 * ```
 */
public class Reservation internal constructor(
    override val javaResource: com.pulumi.gcp.compute.Reservation,
) : KotlinCustomResource(javaResource, ReservationMapper) {
    /**
     * Full or partial URL to a parent commitment. This field displays for
     * reservations that are tied to a commitment.
     */
    public val commitment: Output
        get() = javaResource.commitment().applyValue({ args0 -> args0 })

    /**
     * Creation timestamp in RFC3339 text format.
     */
    public val creationTimestamp: Output
        get() = javaResource.creationTimestamp().applyValue({ args0 -> args0 })

    /**
     * An optional description of this resource.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * 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.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

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

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

    /**
     * The share setting for reservations.
     */
    public val shareSettings: Output
        get() = javaResource.shareSettings().applyValue({ args0 ->
            args0.let({ args0 ->
                reservationShareSettingsToKotlin(args0)
            })
        })

    /**
     * Reservation for instances with specific machine shapes.
     * Structure is documented below.
     */
    public val specificReservation: Output
        get() = javaResource.specificReservation().applyValue({ args0 ->
            args0.let({ args0 ->
                reservationSpecificReservationToKotlin(args0)
            })
        })

    /**
     * When set to true, only VMs that target this reservation by name can consume this reservation. Otherwise, it can be
     * consumed by VMs with affinity for any reservation. Defaults to false.
     */
    public val specificReservationRequired: Output?
        get() = javaResource.specificReservationRequired().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The status of the reservation.
     */
    public val status: Output
        get() = javaResource.status().applyValue({ args0 -> args0 })

    /**
     * The zone where the reservation is made.
     */
    public val zone: Output
        get() = javaResource.zone().applyValue({ args0 -> args0 })
}

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

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy