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

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

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

package com.pulumi.aws.ec2.kotlin

import com.pulumi.aws.ec2.AmiFromInstanceArgs.builder
import com.pulumi.aws.ec2.kotlin.inputs.AmiFromInstanceEbsBlockDeviceArgs
import com.pulumi.aws.ec2.kotlin.inputs.AmiFromInstanceEbsBlockDeviceArgsBuilder
import com.pulumi.aws.ec2.kotlin.inputs.AmiFromInstanceEphemeralBlockDeviceArgs
import com.pulumi.aws.ec2.kotlin.inputs.AmiFromInstanceEphemeralBlockDeviceArgsBuilder
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

/**
 * The "AMI from instance" resource allows the creation of an Amazon Machine
 * Image (AMI) modeled after an existing EBS-backed EC2 instance.
 * The created AMI will refer to implicitly-created snapshots of the instance's
 * EBS volumes and mimick its assigned block device configuration at the time
 * the resource is created.
 * This resource is best applied to an instance that is stopped when this instance
 * is created, so that the contents of the created image are predictable. When
 * applied to an instance that is running, *the instance will be stopped before taking
 * the snapshots and then started back up again*, resulting in a period of
 * downtime.
 * Note that the source instance is inspected only at the initial creation of this
 * resource. Ongoing updates to the referenced instance will not be propagated into
 * the generated AMI. Users may taint or otherwise recreate the resource in order
 * to produce a fresh snapshot.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as aws from "@pulumi/aws";
 * const example = new aws.ec2.AmiFromInstance("example", {
 *     name: "example",
 *     sourceInstanceId: "i-xxxxxxxx",
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_aws as aws
 * example = aws.ec2.AmiFromInstance("example",
 *     name="example",
 *     source_instance_id="i-xxxxxxxx")
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Aws = Pulumi.Aws;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Aws.Ec2.AmiFromInstance("example", new()
 *     {
 *         Name = "example",
 *         SourceInstanceId = "i-xxxxxxxx",
 *     });
 * });
 * ```
 * ```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.NewAmiFromInstance(ctx, "example", &ec2.AmiFromInstanceArgs{
 * 			Name:             pulumi.String("example"),
 * 			SourceInstanceId: pulumi.String("i-xxxxxxxx"),
 * 		})
 * 		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.AmiFromInstance;
 * import com.pulumi.aws.ec2.AmiFromInstanceArgs;
 * 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 example = new AmiFromInstance("example", AmiFromInstanceArgs.builder()
 *             .name("example")
 *             .sourceInstanceId("i-xxxxxxxx")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: aws:ec2:AmiFromInstance
 *     properties:
 *       name: example
 *       sourceInstanceId: i-xxxxxxxx
 * ```
 * 
 * @property deprecationTime Date and time to deprecate the AMI. If you specified a value for seconds, Amazon EC2 rounds the seconds to the nearest minute. Valid values: [RFC3339 time string](https://tools.ietf.org/html/rfc3339#section-5.8) (`YYYY-MM-DDTHH:MM:SSZ`)
 * @property description Longer, human-readable description for the AMI.
 * @property ebsBlockDevices Nested block describing an EBS block device that should be
 * attached to created instances. The structure of this block is described below.
 * @property ephemeralBlockDevices Nested block describing an ephemeral block device that
 * should be attached to created instances. The structure of this block is described below.
 * @property name Region-unique name for the AMI.
 * @property snapshotWithoutReboot Boolean that overrides the behavior of stopping
 * the instance before snapshotting. This is risky since it may cause a snapshot of an
 * inconsistent filesystem state, but can be used to avoid downtime if the user otherwise
 * guarantees that no filesystem writes will be underway at the time of snapshot.
 * @property sourceInstanceId ID of the instance to use as the basis of the AMI.
 * @property tags 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 data class AmiFromInstanceArgs(
    public val deprecationTime: Output? = null,
    public val description: Output? = null,
    public val ebsBlockDevices: Output>? = null,
    public val ephemeralBlockDevices: Output>? = null,
    public val name: Output? = null,
    public val snapshotWithoutReboot: Output? = null,
    public val sourceInstanceId: Output? = null,
    public val tags: Output>? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.aws.ec2.AmiFromInstanceArgs =
        com.pulumi.aws.ec2.AmiFromInstanceArgs.builder()
            .deprecationTime(deprecationTime?.applyValue({ args0 -> args0 }))
            .description(description?.applyValue({ args0 -> args0 }))
            .ebsBlockDevices(
                ebsBlockDevices?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.let({ args0 ->
                            args0.toJava()
                        })
                    })
                }),
            )
            .ephemeralBlockDevices(
                ephemeralBlockDevices?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.let({ args0 -> args0.toJava() })
                    })
                }),
            )
            .name(name?.applyValue({ args0 -> args0 }))
            .snapshotWithoutReboot(snapshotWithoutReboot?.applyValue({ args0 -> args0 }))
            .sourceInstanceId(sourceInstanceId?.applyValue({ args0 -> args0 }))
            .tags(
                tags?.applyValue({ args0 ->
                    args0.map({ args0 ->
                        args0.key.to(args0.value)
                    }).toMap()
                }),
            ).build()
}

/**
 * Builder for [AmiFromInstanceArgs].
 */
@PulumiTagMarker
public class AmiFromInstanceArgsBuilder internal constructor() {
    private var deprecationTime: Output? = null

    private var description: Output? = null

    private var ebsBlockDevices: Output>? = null

    private var ephemeralBlockDevices: Output>? = null

    private var name: Output? = null

    private var snapshotWithoutReboot: Output? = null

    private var sourceInstanceId: Output? = null

    private var tags: Output>? = null

    /**
     * @param value Date and time to deprecate the AMI. If you specified a value for seconds, Amazon EC2 rounds the seconds to the nearest minute. Valid values: [RFC3339 time string](https://tools.ietf.org/html/rfc3339#section-5.8) (`YYYY-MM-DDTHH:MM:SSZ`)
     */
    @JvmName("vpypjeumuwxdnxpn")
    public suspend fun deprecationTime(`value`: Output) {
        this.deprecationTime = value
    }

    /**
     * @param value Longer, human-readable description for the AMI.
     */
    @JvmName("hdfywgieqagqdbww")
    public suspend fun description(`value`: Output) {
        this.description = value
    }

    /**
     * @param value Nested block describing an EBS block device that should be
     * attached to created instances. The structure of this block is described below.
     */
    @JvmName("ulweotxvceweansi")
    public suspend fun ebsBlockDevices(`value`: Output>) {
        this.ebsBlockDevices = value
    }

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

    /**
     * @param values Nested block describing an EBS block device that should be
     * attached to created instances. The structure of this block is described below.
     */
    @JvmName("oouitdqnyidygnhq")
    public suspend fun ebsBlockDevices(values: List>) {
        this.ebsBlockDevices = Output.all(values)
    }

    /**
     * @param value Nested block describing an ephemeral block device that
     * should be attached to created instances. The structure of this block is described below.
     */
    @JvmName("smcidhsyuqwkcsjb")
    public suspend fun ephemeralBlockDevices(`value`: Output>) {
        this.ephemeralBlockDevices = value
    }

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

    /**
     * @param values Nested block describing an ephemeral block device that
     * should be attached to created instances. The structure of this block is described below.
     */
    @JvmName("ussccenhpbmpigwg")
    public suspend fun ephemeralBlockDevices(values: List>) {
        this.ephemeralBlockDevices = Output.all(values)
    }

    /**
     * @param value Region-unique name for the AMI.
     */
    @JvmName("lgmfwvyyxjdaclpl")
    public suspend fun name(`value`: Output) {
        this.name = value
    }

    /**
     * @param value Boolean that overrides the behavior of stopping
     * the instance before snapshotting. This is risky since it may cause a snapshot of an
     * inconsistent filesystem state, but can be used to avoid downtime if the user otherwise
     * guarantees that no filesystem writes will be underway at the time of snapshot.
     */
    @JvmName("vxvncwbjkeriydpw")
    public suspend fun snapshotWithoutReboot(`value`: Output) {
        this.snapshotWithoutReboot = value
    }

    /**
     * @param value ID of the instance to use as the basis of the AMI.
     */
    @JvmName("bfhikpgrgbstcjou")
    public suspend fun sourceInstanceId(`value`: Output) {
        this.sourceInstanceId = value
    }

    /**
     * @param value 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.
     */
    @JvmName("hdtfcqlobgovyvmq")
    public suspend fun tags(`value`: Output>) {
        this.tags = value
    }

    /**
     * @param value Date and time to deprecate the AMI. If you specified a value for seconds, Amazon EC2 rounds the seconds to the nearest minute. Valid values: [RFC3339 time string](https://tools.ietf.org/html/rfc3339#section-5.8) (`YYYY-MM-DDTHH:MM:SSZ`)
     */
    @JvmName("qnqvnpxhttpemsfk")
    public suspend fun deprecationTime(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.deprecationTime = mapped
    }

    /**
     * @param value Longer, human-readable description for the AMI.
     */
    @JvmName("dyeymgfvjusrtoho")
    public suspend fun description(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.description = mapped
    }

    /**
     * @param value Nested block describing an EBS block device that should be
     * attached to created instances. The structure of this block is described below.
     */
    @JvmName("xaslvhoaudshmcxc")
    public suspend fun ebsBlockDevices(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.ebsBlockDevices = mapped
    }

    /**
     * @param argument Nested block describing an EBS block device that should be
     * attached to created instances. The structure of this block is described below.
     */
    @JvmName("jfrdrpwwiakufunk")
    public suspend fun ebsBlockDevices(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            AmiFromInstanceEbsBlockDeviceArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.ebsBlockDevices = mapped
    }

    /**
     * @param argument Nested block describing an EBS block device that should be
     * attached to created instances. The structure of this block is described below.
     */
    @JvmName("aitcltpdqytwgvvn")
    public suspend fun ebsBlockDevices(vararg argument: suspend AmiFromInstanceEbsBlockDeviceArgsBuilder.() -> Unit) {
        val toBeMapped = argument.toList().map {
            AmiFromInstanceEbsBlockDeviceArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.ebsBlockDevices = mapped
    }

    /**
     * @param argument Nested block describing an EBS block device that should be
     * attached to created instances. The structure of this block is described below.
     */
    @JvmName("isprwuihdjujggqd")
    public suspend fun ebsBlockDevices(argument: suspend AmiFromInstanceEbsBlockDeviceArgsBuilder.() -> Unit) {
        val toBeMapped = listOf(
            AmiFromInstanceEbsBlockDeviceArgsBuilder().applySuspend {
                argument()
            }.build(),
        )
        val mapped = of(toBeMapped)
        this.ebsBlockDevices = mapped
    }

    /**
     * @param values Nested block describing an EBS block device that should be
     * attached to created instances. The structure of this block is described below.
     */
    @JvmName("pdignfuuevmsvavv")
    public suspend fun ebsBlockDevices(vararg values: AmiFromInstanceEbsBlockDeviceArgs) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.ebsBlockDevices = mapped
    }

    /**
     * @param value Nested block describing an ephemeral block device that
     * should be attached to created instances. The structure of this block is described below.
     */
    @JvmName("fuwtprlbyjoydeln")
    public suspend fun ephemeralBlockDevices(`value`: List?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.ephemeralBlockDevices = mapped
    }

    /**
     * @param argument Nested block describing an ephemeral block device that
     * should be attached to created instances. The structure of this block is described below.
     */
    @JvmName("twcesoooflmfmtpu")
    public suspend fun ephemeralBlockDevices(argument: List Unit>) {
        val toBeMapped = argument.toList().map {
            AmiFromInstanceEphemeralBlockDeviceArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.ephemeralBlockDevices = mapped
    }

    /**
     * @param argument Nested block describing an ephemeral block device that
     * should be attached to created instances. The structure of this block is described below.
     */
    @JvmName("pxsmcncmxdmgflee")
    public suspend fun ephemeralBlockDevices(vararg argument: suspend AmiFromInstanceEphemeralBlockDeviceArgsBuilder.() -> Unit) {
        val toBeMapped = argument.toList().map {
            AmiFromInstanceEphemeralBlockDeviceArgsBuilder().applySuspend { it() }.build()
        }
        val mapped = of(toBeMapped)
        this.ephemeralBlockDevices = mapped
    }

    /**
     * @param argument Nested block describing an ephemeral block device that
     * should be attached to created instances. The structure of this block is described below.
     */
    @JvmName("psaqwxlmbykcgdsr")
    public suspend fun ephemeralBlockDevices(argument: suspend AmiFromInstanceEphemeralBlockDeviceArgsBuilder.() -> Unit) {
        val toBeMapped = listOf(
            AmiFromInstanceEphemeralBlockDeviceArgsBuilder().applySuspend {
                argument()
            }.build(),
        )
        val mapped = of(toBeMapped)
        this.ephemeralBlockDevices = mapped
    }

    /**
     * @param values Nested block describing an ephemeral block device that
     * should be attached to created instances. The structure of this block is described below.
     */
    @JvmName("hpuhcwriksephuub")
    public suspend fun ephemeralBlockDevices(vararg values: AmiFromInstanceEphemeralBlockDeviceArgs) {
        val toBeMapped = values.toList()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.ephemeralBlockDevices = mapped
    }

    /**
     * @param value Region-unique name for the AMI.
     */
    @JvmName("noabvqucaxyvwtbg")
    public suspend fun name(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.name = mapped
    }

    /**
     * @param value Boolean that overrides the behavior of stopping
     * the instance before snapshotting. This is risky since it may cause a snapshot of an
     * inconsistent filesystem state, but can be used to avoid downtime if the user otherwise
     * guarantees that no filesystem writes will be underway at the time of snapshot.
     */
    @JvmName("rftroorrukgfnqrk")
    public suspend fun snapshotWithoutReboot(`value`: Boolean?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.snapshotWithoutReboot = mapped
    }

    /**
     * @param value ID of the instance to use as the basis of the AMI.
     */
    @JvmName("auujhafkgwfapfsy")
    public suspend fun sourceInstanceId(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.sourceInstanceId = mapped
    }

    /**
     * @param value 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.
     */
    @JvmName("cduicjegjupiltdi")
    public suspend fun tags(`value`: Map?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.tags = mapped
    }

    /**
     * @param values 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.
     */
    @JvmName("ktptmxcypbfajskx")
    public fun tags(vararg values: Pair) {
        val toBeMapped = values.toMap()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.tags = mapped
    }

    internal fun build(): AmiFromInstanceArgs = AmiFromInstanceArgs(
        deprecationTime = deprecationTime,
        description = description,
        ebsBlockDevices = ebsBlockDevices,
        ephemeralBlockDevices = ephemeralBlockDevices,
        name = name,
        snapshotWithoutReboot = snapshotWithoutReboot,
        sourceInstanceId = sourceInstanceId,
        tags = tags,
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy