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

com.pulumi.gcp.kms.kotlin.CryptoKeyVersion.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.10.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.kms.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.kms.kotlin.outputs.CryptoKeyVersionAttestation
import com.pulumi.gcp.kms.kotlin.outputs.CryptoKeyVersionExternalProtectionLevelOptions
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.gcp.kms.kotlin.outputs.CryptoKeyVersionAttestation.Companion.toKotlin as cryptoKeyVersionAttestationToKotlin
import com.pulumi.gcp.kms.kotlin.outputs.CryptoKeyVersionExternalProtectionLevelOptions.Companion.toKotlin as cryptoKeyVersionExternalProtectionLevelOptionsToKotlin

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

    public var args: CryptoKeyVersionArgs = CryptoKeyVersionArgs()

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

/**
 * A `CryptoKeyVersion` represents an individual cryptographic key, and the associated key material.
 * Destroying a cryptoKeyVersion will not delete the resource from the project.
 * To get more information about CryptoKeyVersion, see:
 * * [API documentation](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions)
 * * How-to Guides
 *     * [Creating a key Version](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys.cryptoKeyVersions/create)
 * ## Example Usage
 * ### Kms Crypto Key Version Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const keyring = new gcp.kms.KeyRing("keyring", {
 *     name: "keyring-example",
 *     location: "global",
 * });
 * const cryptokey = new gcp.kms.CryptoKey("cryptokey", {
 *     name: "crypto-key-example",
 *     keyRing: keyring.id,
 *     rotationPeriod: "7776000s",
 * });
 * const example_key = new gcp.kms.CryptoKeyVersion("example-key", {cryptoKey: cryptokey.id});
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * keyring = gcp.kms.KeyRing("keyring",
 *     name="keyring-example",
 *     location="global")
 * cryptokey = gcp.kms.CryptoKey("cryptokey",
 *     name="crypto-key-example",
 *     key_ring=keyring.id,
 *     rotation_period="7776000s")
 * example_key = gcp.kms.CryptoKeyVersion("example-key", crypto_key=cryptokey.id)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var keyring = new Gcp.Kms.KeyRing("keyring", new()
 *     {
 *         Name = "keyring-example",
 *         Location = "global",
 *     });
 *     var cryptokey = new Gcp.Kms.CryptoKey("cryptokey", new()
 *     {
 *         Name = "crypto-key-example",
 *         KeyRing = keyring.Id,
 *         RotationPeriod = "7776000s",
 *     });
 *     var example_key = new Gcp.Kms.CryptoKeyVersion("example-key", new()
 *     {
 *         CryptoKey = cryptokey.Id,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/kms"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		keyring, err := kms.NewKeyRing(ctx, "keyring", &kms.KeyRingArgs{
 * 			Name:     pulumi.String("keyring-example"),
 * 			Location: pulumi.String("global"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		cryptokey, err := kms.NewCryptoKey(ctx, "cryptokey", &kms.CryptoKeyArgs{
 * 			Name:           pulumi.String("crypto-key-example"),
 * 			KeyRing:        keyring.ID(),
 * 			RotationPeriod: pulumi.String("7776000s"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = kms.NewCryptoKeyVersion(ctx, "example-key", &kms.CryptoKeyVersionArgs{
 * 			CryptoKey: cryptokey.ID(),
 * 		})
 * 		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.kms.KeyRing;
 * import com.pulumi.gcp.kms.KeyRingArgs;
 * import com.pulumi.gcp.kms.CryptoKey;
 * import com.pulumi.gcp.kms.CryptoKeyArgs;
 * import com.pulumi.gcp.kms.CryptoKeyVersion;
 * import com.pulumi.gcp.kms.CryptoKeyVersionArgs;
 * 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 keyring = new KeyRing("keyring", KeyRingArgs.builder()
 *             .name("keyring-example")
 *             .location("global")
 *             .build());
 *         var cryptokey = new CryptoKey("cryptokey", CryptoKeyArgs.builder()
 *             .name("crypto-key-example")
 *             .keyRing(keyring.id())
 *             .rotationPeriod("7776000s")
 *             .build());
 *         var example_key = new CryptoKeyVersion("example-key", CryptoKeyVersionArgs.builder()
 *             .cryptoKey(cryptokey.id())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   keyring:
 *     type: gcp:kms:KeyRing
 *     properties:
 *       name: keyring-example
 *       location: global
 *   cryptokey:
 *     type: gcp:kms:CryptoKey
 *     properties:
 *       name: crypto-key-example
 *       keyRing: ${keyring.id}
 *       rotationPeriod: 7776000s
 *   example-key:
 *     type: gcp:kms:CryptoKeyVersion
 *     properties:
 *       cryptoKey: ${cryptokey.id}
 * ```
 * 
 * ## Import
 * CryptoKeyVersion can be imported using any of these accepted formats:
 * * `{{name}}`
 * When using the `pulumi import` command, CryptoKeyVersion can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:kms/cryptoKeyVersion:CryptoKeyVersion default {{name}}
 * ```
 */
public class CryptoKeyVersion internal constructor(
    override val javaResource: com.pulumi.gcp.kms.CryptoKeyVersion,
) : KotlinCustomResource(javaResource, CryptoKeyVersionMapper) {
    /**
     * The CryptoKeyVersionAlgorithm that this CryptoKeyVersion supports.
     */
    public val algorithm: Output
        get() = javaResource.algorithm().applyValue({ args0 -> args0 })

    /**
     * Statement that was generated and signed by the HSM at key creation time. Use this statement to verify attributes of the key as stored on the HSM, independently of Google.
     * Only provided for key versions with protectionLevel HSM.
     * Structure is documented below.
     */
    public val attestations: Output>
        get() = javaResource.attestations().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    cryptoKeyVersionAttestationToKotlin(args0)
                })
            })
        })

    /**
     * The name of the cryptoKey associated with the CryptoKeyVersions.
     * Format: `'projects/{{project}}/locations/{{location}}/keyRings/{{keyring}}/cryptoKeys/{{cryptoKey}}'`
     * - - -
     */
    public val cryptoKey: Output
        get() = javaResource.cryptoKey().applyValue({ args0 -> args0 })

    /**
     * ExternalProtectionLevelOptions stores a group of additional fields for configuring a CryptoKeyVersion that are specific to the EXTERNAL protection level and EXTERNAL_VPC protection levels.
     * Structure is documented below.
     */
    public val externalProtectionLevelOptions: Output?
        get() = javaResource.externalProtectionLevelOptions().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    cryptoKeyVersionExternalProtectionLevelOptionsToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * The time this CryptoKeyVersion key material was generated
     */
    public val generateTime: Output
        get() = javaResource.generateTime().applyValue({ args0 -> args0 })

    /**
     * The resource name for this CryptoKeyVersion.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The ProtectionLevel describing how crypto operations are performed with this CryptoKeyVersion.
     */
    public val protectionLevel: Output
        get() = javaResource.protectionLevel().applyValue({ args0 -> args0 })

    /**
     * The current state of the CryptoKeyVersion.
     * Possible values are: `PENDING_GENERATION`, `ENABLED`, `DISABLED`, `DESTROYED`, `DESTROY_SCHEDULED`, `PENDING_IMPORT`, `IMPORT_FAILED`.
     */
    public val state: Output
        get() = javaResource.state().applyValue({ args0 -> args0 })
}

public object CryptoKeyVersionMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.kms.CryptoKeyVersion::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy