"use strict";
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.CryptoKey = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * A `CryptoKey` represents a logical key that can be used for cryptographic operations.
 *
 * > **Note:** CryptoKeys cannot be deleted from Google Cloud Platform.
 * Destroying a provider-managed CryptoKey will remove it from state
 * and delete all CryptoKeyVersions, rendering the key unusable, but *will
 * not delete the resource from the project.* When the provider destroys these keys,
 * any data previously encrypted with these keys will be irrecoverable.
 * For this reason, it is strongly recommended that you use Pulumi's [protect resource option](https://www.pulumi.com/docs/concepts/options/protect/).
 *
 * To get more information about CryptoKey, see:
 *
 * * [API documentation](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys)
 * * How-to Guides
 *     * [Creating a key](https://cloud.google.com/kms/docs/creating-keys#create_a_key)
 *
 * ## Example Usage
 *
 * ### Kms Crypto Key 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 example_key = new gcp.kms.CryptoKey("example-key", {
 *     name: "crypto-key-example",
 *     keyRing: keyring.id,
 *     rotationPeriod: "7776000s",
 * });
 * ```
 * ### Kms Crypto Key Asymmetric Sign
 *
 * ```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 example_asymmetric_sign_key = new gcp.kms.CryptoKey("example-asymmetric-sign-key", {
 *     name: "crypto-key-example",
 *     keyRing: keyring.id,
 *     purpose: "ASYMMETRIC_SIGN",
 *     versionTemplate: {
 *         algorithm: "EC_SIGN_P384_SHA384",
 *     },
 * });
 * ```
 *
 * ## Import
 *
 * CryptoKey can be imported using any of these accepted formats:
 *
 * * `{{key_ring}}/cryptoKeys/{{name}}`
 *
 * * `{{key_ring}}/{{name}}`
 *
 * When using the `pulumi import` command, CryptoKey can be imported using one of the formats above. For example:
 *
 * ```sh
 * $ pulumi import gcp:kms/cryptoKey:CryptoKey default {{key_ring}}/cryptoKeys/{{name}}
 * ```
 *
 * ```sh
 * $ pulumi import gcp:kms/cryptoKey:CryptoKey default {{key_ring}}/{{name}}
 * ```
 */
class CryptoKey extends pulumi.CustomResource {
    /**
     * Get an existing CryptoKey resource's state with the given name, ID, and optional extra
     * properties used to qualify the lookup.
     *
     * @param name The _unique_ name of the resulting resource.
     * @param id The _unique_ provider ID of the resource to lookup.
     * @param state Any extra arguments used during the lookup.
     * @param opts Optional settings to control the behavior of the CustomResource.
     */
    static get(name, id, state, opts) {
        return new CryptoKey(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of CryptoKey.  This is designed to work even
     * when multiple copies of the Pulumi SDK have been loaded into the same process.
     */
    static isInstance(obj) {
        if (obj === undefined || obj === null) {
            return false;
        }
        return obj['__pulumiType'] === CryptoKey.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["cryptoKeyBackend"] = state?.cryptoKeyBackend;
            resourceInputs["destroyScheduledDuration"] = state?.destroyScheduledDuration;
            resourceInputs["effectiveLabels"] = state?.effectiveLabels;
            resourceInputs["importOnly"] = state?.importOnly;
            resourceInputs["keyAccessJustificationsPolicy"] = state?.keyAccessJustificationsPolicy;
            resourceInputs["keyRing"] = state?.keyRing;
            resourceInputs["labels"] = state?.labels;
            resourceInputs["name"] = state?.name;
            resourceInputs["primaries"] = state?.primaries;
            resourceInputs["pulumiLabels"] = state?.pulumiLabels;
            resourceInputs["purpose"] = state?.purpose;
            resourceInputs["rotationPeriod"] = state?.rotationPeriod;
            resourceInputs["skipInitialVersionCreation"] = state?.skipInitialVersionCreation;
            resourceInputs["versionTemplate"] = state?.versionTemplate;
        }
        else {
            const args = argsOrState;
            if (args?.keyRing === undefined && !opts.urn) {
                throw new Error("Missing required property 'keyRing'");
            }
            resourceInputs["cryptoKeyBackend"] = args?.cryptoKeyBackend;
            resourceInputs["destroyScheduledDuration"] = args?.destroyScheduledDuration;
            resourceInputs["importOnly"] = args?.importOnly;
            resourceInputs["keyAccessJustificationsPolicy"] = args?.keyAccessJustificationsPolicy;
            resourceInputs["keyRing"] = args?.keyRing;
            resourceInputs["labels"] = args?.labels;
            resourceInputs["name"] = args?.name;
            resourceInputs["purpose"] = args?.purpose;
            resourceInputs["rotationPeriod"] = args?.rotationPeriod;
            resourceInputs["skipInitialVersionCreation"] = args?.skipInitialVersionCreation;
            resourceInputs["versionTemplate"] = args?.versionTemplate;
            resourceInputs["effectiveLabels"] = undefined /*out*/;
            resourceInputs["primaries"] = undefined /*out*/;
            resourceInputs["pulumiLabels"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] };
        opts = pulumi.mergeOptions(opts, secretOpts);
        super(CryptoKey.__pulumiType, name, resourceInputs, opts);
    }
}
exports.CryptoKey = CryptoKey;
/** @internal */
CryptoKey.__pulumiType = 'gcp:kms/cryptoKey:CryptoKey';
//# sourceMappingURL=cryptoKey.js.map