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

com.pulumi.aws.ec2.kotlin.CapacityReservation.kt Maven / Gradle / Ivy

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

package com.pulumi.aws.ec2.kotlin

import com.pulumi.core.Output
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.Deprecated
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map

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

    public var args: CapacityReservationArgs = CapacityReservationArgs()

    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 CapacityReservationArgsBuilder.() -> Unit) {
        val builder = CapacityReservationArgsBuilder()
        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(): CapacityReservation {
        val builtJavaResource = com.pulumi.aws.ec2.CapacityReservation(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return CapacityReservation(builtJavaResource)
    }
}

/**
 * Provides an EC2 Capacity Reservation. This allows you to reserve capacity for your Amazon EC2 instances in a specific Availability Zone for any duration.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 * const _default = new aws.ec2.CapacityReservation("default", {
 *     instanceType: aws.ec2.InstanceType.T2_Micro,
 *     instancePlatform: aws.ec2.InstancePlatform.LinuxUnix,
 *     availabilityZone: "eu-west-1a",
 *     instanceCount: 1,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_aws as aws
 * default = aws.ec2.CapacityReservation("default",
 *     instance_type=aws.ec2.InstanceType.T2_MICRO,
 *     instance_platform=aws.ec2.InstancePlatform.LINUX_UNIX,
 *     availability_zone="eu-west-1a",
 *     instance_count=1)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Aws = Pulumi.Aws;
 * return await Deployment.RunAsync(() =>
 * {
 *     var @default = new Aws.Ec2.CapacityReservation("default", new()
 *     {
 *         InstanceType = Aws.Ec2.InstanceType.T2_Micro,
 *         InstancePlatform = Aws.Ec2.InstancePlatform.LinuxUnix,
 *         AvailabilityZone = "eu-west-1a",
 *         InstanceCount = 1,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := ec2.NewCapacityReservation(ctx, "default", &ec2.CapacityReservationArgs{
 * 			InstanceType:     pulumi.String(ec2.InstanceType_T2_Micro),
 * 			InstancePlatform: pulumi.String(ec2.InstancePlatformLinuxUnix),
 * 			AvailabilityZone: pulumi.String("eu-west-1a"),
 * 			InstanceCount:    pulumi.Int(1),
 * 		})
 * 		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.aws.ec2.CapacityReservation;
 * import com.pulumi.aws.ec2.CapacityReservationArgs;
 * 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 default_ = new CapacityReservation("default", CapacityReservationArgs.builder()
 *             .instanceType("t2.micro")
 *             .instancePlatform("Linux/UNIX")
 *             .availabilityZone("eu-west-1a")
 *             .instanceCount(1)
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   default:
 *     type: aws:ec2:CapacityReservation
 *     properties:
 *       instanceType: t2.micro
 *       instancePlatform: Linux/UNIX
 *       availabilityZone: eu-west-1a
 *       instanceCount: 1
 * ```
 * 
 * ## Import
 * Using `pulumi import`, import Capacity Reservations using the `id`. For example:
 * ```sh
 * $ pulumi import aws:ec2/capacityReservation:CapacityReservation web cr-0123456789abcdef0
 * ```
 */
public class CapacityReservation internal constructor(
    override val javaResource: com.pulumi.aws.ec2.CapacityReservation,
) : KotlinCustomResource(javaResource, CapacityReservationMapper) {
    /**
     * The ARN of the Capacity Reservation.
     */
    public val arn: Output
        get() = javaResource.arn().applyValue({ args0 -> args0 })

    /**
     * The Availability Zone in which to create the Capacity Reservation.
     */
    public val availabilityZone: Output
        get() = javaResource.availabilityZone().applyValue({ args0 -> args0 })

    /**
     * Indicates whether the Capacity Reservation supports EBS-optimized instances.
     */
    public val ebsOptimized: Output?
        get() = javaResource.ebsOptimized().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The date and time at which the Capacity Reservation expires. When a Capacity Reservation expires, the reserved capacity is released and you can no longer launch instances into it. Valid values: [RFC3339 time string](https://tools.ietf.org/html/rfc3339#section-5.8) (`YYYY-MM-DDTHH:MM:SSZ`)
     */
    public val endDate: Output?
        get() = javaResource.endDate().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * Indicates the way in which the Capacity Reservation ends. Specify either `unlimited` or `limited`.
     */
    public val endDateType: Output?
        get() = javaResource.endDateType().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Indicates whether the Capacity Reservation supports instances with temporary, block-level storage.
     */
    public val ephemeralStorage: Output?
        get() = javaResource.ephemeralStorage().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The number of instances for which to reserve capacity.
     */
    public val instanceCount: Output
        get() = javaResource.instanceCount().applyValue({ args0 -> args0 })

    /**
     * Indicates the type of instance launches that the Capacity Reservation accepts. Specify either `open` or `targeted`.
     */
    public val instanceMatchCriteria: Output?
        get() = javaResource.instanceMatchCriteria().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The type of operating system for which to reserve capacity. Valid options are `Linux/UNIX`, `Red Hat Enterprise Linux`, `SUSE Linux`, `Windows`, `Windows with SQL Server`, `Windows with SQL Server Enterprise`, `Windows with SQL Server Standard` or `Windows with SQL Server Web`.
     */
    public val instancePlatform: Output
        get() = javaResource.instancePlatform().applyValue({ args0 -> args0 })

    /**
     * The instance type for which to reserve capacity.
     */
    public val instanceType: Output
        get() = javaResource.instanceType().applyValue({ args0 -> args0 })

    /**
     * The Amazon Resource Name (ARN) of the Outpost on which to create the Capacity Reservation.
     */
    public val outpostArn: Output?
        get() = javaResource.outpostArn().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The ID of the AWS account that owns the Capacity Reservation.
     */
    public val ownerId: Output
        get() = javaResource.ownerId().applyValue({ args0 -> args0 })

    /**
     * The Amazon Resource Name (ARN) of the cluster placement group in which to create the Capacity Reservation.
     */
    public val placementGroupArn: Output?
        get() = javaResource.placementGroupArn().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * A map of tags to assign to the resource. If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * A map of tags assigned to the resource, including those inherited from the provider `default_tags` configuration block
     */
    @Deprecated(
        message = """
  Please use `tags` instead.
  """,
    )
    public val tagsAll: Output>
        get() = javaResource.tagsAll().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * Indicates the tenancy of the Capacity Reservation. Specify either `default` or `dedicated`.
     */
    public val tenancy: Output?
        get() = javaResource.tenancy().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
}

public object CapacityReservationMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.aws.ec2.CapacityReservation::class == javaResource::class

    override fun map(javaResource: Resource): CapacityReservation = CapacityReservation(
        javaResource
            as com.pulumi.aws.ec2.CapacityReservation,
    )
}

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy