com.pulumi.awsnative.ec2.kotlin.KeyPair.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.awsnative.ec2.kotlin
import com.pulumi.awsnative.ec2.kotlin.enums.KeyPairKeyFormat
import com.pulumi.awsnative.ec2.kotlin.enums.KeyPairKeyType
import com.pulumi.awsnative.kotlin.outputs.CreateOnlyTag
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
import kotlin.collections.List
import com.pulumi.awsnative.ec2.kotlin.enums.KeyPairKeyFormat.Companion.toKotlin as keyPairKeyFormatToKotlin
import com.pulumi.awsnative.ec2.kotlin.enums.KeyPairKeyType.Companion.toKotlin as keyPairKeyTypeToKotlin
import com.pulumi.awsnative.kotlin.outputs.CreateOnlyTag.Companion.toKotlin as createOnlyTagToKotlin
/**
* Builder for [KeyPair].
*/
@PulumiTagMarker
public class KeyPairResourceBuilder internal constructor() {
public var name: String? = null
public var args: KeyPairArgs = KeyPairArgs()
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 KeyPairArgsBuilder.() -> Unit) {
val builder = KeyPairArgsBuilder()
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(): KeyPair {
val builtJavaResource = com.pulumi.awsnative.ec2.KeyPair(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return KeyPair(builtJavaResource)
}
}
/**
* Specifies a key pair for use with an EC2long instance as follows:
* + To import an existing key pair, include the ``PublicKeyMaterial`` property.
* + To create a new key pair, omit the ``PublicKeyMaterial`` property.
* When you import an existing key pair, you specify the public key material for the key. We assume that you have the private key material for the key. CFNlong does not create or return the private key material when you import a key pair.
* When you create a new key pair, the private key is saved to SYSlong Parameter Store, using a parameter with the following name: ``/ec2/keypair/{key_pair_id}``. For more information about retrieving private key, and the required permissions, see [Create a key pair using](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html#create-key-pair-cloudformation) in the *User Guide*.
* When CFN deletes a key pair that was created or imported by a stack, it also deletes the parameter that was used to store the private key material in Parameter Store.
* ## Example Usage
* ### Example
* No Java example available.
* ### Example
* No Java example available.
* ### Example
* No Java example available.
* ### Example
* No Java example available.
*/
public class KeyPair internal constructor(
override val javaResource: com.pulumi.awsnative.ec2.KeyPair,
) : KotlinCustomResource(javaResource, KeyPairMapper) {
/**
* If you created the key pair using Amazon EC2:
* - For RSA key pairs, the key fingerprint is the SHA-1 digest of the DER encoded private key.
* - For ED25519 key pairs, the key fingerprint is the base64-encoded SHA-256 digest, which is the default for OpenSSH, starting with [OpenSSH 6.8](https://docs.aws.amazon.com/http://www.openssh.com/txt/release-6.8) .
* If you imported the key pair to Amazon EC2:
* - For RSA key pairs, the key fingerprint is the MD5 public key fingerprint as specified in section 4 of RFC 4716.
* - For ED25519 key pairs, the key fingerprint is the base64-encoded SHA-256 digest, which is the default for OpenSSH, starting with [OpenSSH 6.8](https://docs.aws.amazon.com/http://www.openssh.com/txt/release-6.8) .
*/
public val keyFingerprint: Output
get() = javaResource.keyFingerprint().applyValue({ args0 -> args0 })
/**
* The format of the key pair.
* Default: ``pem``
*/
public val keyFormat: Output?
get() = javaResource.keyFormat().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
keyPairKeyFormatToKotlin(args0)
})
}).orElse(null)
})
/**
* A unique name for the key pair.
* Constraints: Up to 255 ASCII characters
*/
public val keyName: Output
get() = javaResource.keyName().applyValue({ args0 -> args0 })
/**
* The ID of the key pair.
*/
public val keyPairId: Output
get() = javaResource.keyPairId().applyValue({ args0 -> args0 })
/**
* The type of key pair. Note that ED25519 keys are not supported for Windows instances.
* If the ``PublicKeyMaterial`` property is specified, the ``KeyType`` property is ignored, and the key type is inferred from the ``PublicKeyMaterial`` value.
* Default: ``rsa``
*/
public val keyType: Output?
get() = javaResource.keyType().applyValue({ args0 ->
args0.map({ args0 ->
args0.let({ args0 ->
keyPairKeyTypeToKotlin(args0)
})
}).orElse(null)
})
/**
* The public key material. The ``PublicKeyMaterial`` property is used to import a key pair. If this property is not specified, then a new key pair will be created.
*/
public val publicKeyMaterial: Output?
get() = javaResource.publicKeyMaterial().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* The tags to apply to the key pair.
*/
public val tags: Output>?
get() = javaResource.tags().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> createOnlyTagToKotlin(args0) })
})
}).orElse(null)
})
}
public object KeyPairMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.awsnative.ec2.KeyPair::class == javaResource::class
override fun map(javaResource: Resource): KeyPair = KeyPair(
javaResource as
com.pulumi.awsnative.ec2.KeyPair,
)
}
/**
* @see [KeyPair].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [KeyPair].
*/
public suspend fun keyPair(name: String, block: suspend KeyPairResourceBuilder.() -> Unit): KeyPair {
val builder = KeyPairResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [KeyPair].
* @param name The _unique_ name of the resulting resource.
*/
public fun keyPair(name: String): KeyPair {
val builder = KeyPairResourceBuilder()
builder.name(name)
return builder.build()
}