com.pulumi.awsnative.ec2.kotlin.VolumeAttachment.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.awsnative.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.String
import kotlin.Suppress
import kotlin.Unit
/**
* Builder for [VolumeAttachment].
*/
@PulumiTagMarker
public class VolumeAttachmentResourceBuilder internal constructor() {
public var name: String? = null
public var args: VolumeAttachmentArgs = VolumeAttachmentArgs()
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 VolumeAttachmentArgsBuilder.() -> Unit) {
val builder = VolumeAttachmentArgsBuilder()
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(): VolumeAttachment {
val builtJavaResource = com.pulumi.awsnative.ec2.VolumeAttachment(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return VolumeAttachment(builtJavaResource)
}
}
/**
* Attaches an Amazon EBS volume to a running instance and exposes it to the instance with the specified device name.
* Before this resource can be deleted (and therefore the volume detached), you must first unmount the volume in the instance. Failure to do so results in the volume being stuck in the busy state while it is trying to detach, which could possibly damage the file system or the data it contains.
* If an Amazon EBS volume is the root device of an instance, it cannot be detached while the instance is in the "running" state. To detach the root volume, stop the instance first.
* If the root volume is detached from an instance with an MKT product code, then the product codes from that volume are no longer associated with the instance.
*/
public class VolumeAttachment internal constructor(
override val javaResource: com.pulumi.awsnative.ec2.VolumeAttachment,
) : KotlinCustomResource(javaResource, VolumeAttachmentMapper) {
/**
* The device name (for example, ``/dev/sdh`` or ``xvdh``).
*/
public val device: Output?
get() = javaResource.device().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* The ID of the instance to which the volume attaches. This value can be a reference to an [AWS::EC2::Instance](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-instance.html) resource, or it can be the physical ID of an existing EC2 instance.
*/
public val instanceId: Output
get() = javaResource.instanceId().applyValue({ args0 -> args0 })
/**
* The ID of the Amazon EBS volume. The volume and instance must be within the same Availability Zone. This value can be a reference to an [AWS::EC2::Volume](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-ebs-volume.html) resource, or it can be the volume ID of an existing Amazon EBS volume.
*/
public val volumeId: Output
get() = javaResource.volumeId().applyValue({ args0 -> args0 })
}
public object VolumeAttachmentMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.awsnative.ec2.VolumeAttachment::class == javaResource::class
override fun map(javaResource: Resource): VolumeAttachment = VolumeAttachment(
javaResource as
com.pulumi.awsnative.ec2.VolumeAttachment,
)
}
/**
* @see [VolumeAttachment].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [VolumeAttachment].
*/
public suspend fun volumeAttachment(
name: String,
block: suspend VolumeAttachmentResourceBuilder.() -> Unit,
): VolumeAttachment {
val builder = VolumeAttachmentResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [VolumeAttachment].
* @param name The _unique_ name of the resulting resource.
*/
public fun volumeAttachment(name: String): VolumeAttachment {
val builder = VolumeAttachmentResourceBuilder()
builder.name(name)
return builder.build()
}