"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.Key = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
 * ## Example Usage
 *
 * ### Creating A New Key
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 *
 * const myaccount = new gcp.serviceaccount.Account("myaccount", {
 *     accountId: "myaccount",
 *     displayName: "My Service Account",
 * });
 * const mykey = new gcp.serviceaccount.Key("mykey", {
 *     serviceAccountId: myaccount.name,
 *     publicKeyType: "TYPE_X509_PEM_FILE",
 * });
 * ```
 *
 * ### Creating And Regularly Rotating A Key
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * import * as time from "@pulumiverse/time";
 *
 * const myaccount = new gcp.serviceaccount.Account("myaccount", {
 *     accountId: "myaccount",
 *     displayName: "My Service Account",
 * });
 * // note this requires the terraform to be run regularly
 * const mykeyRotation = new time.Rotating("mykey_rotation", {rotationDays: 30});
 * const mykey = new gcp.serviceaccount.Key("mykey", {
 *     serviceAccountId: myaccount.name,
 *     keepers: {
 *         rotation_time: mykeyRotation.rotationRfc3339,
 *     },
 * });
 * ```
 *
 * ### Save Key In Kubernetes Secret - DEPRECATED
 *
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * import * as kubernetes from "@pulumi/kubernetes";
 * import * as std from "@pulumi/std";
 *
 * // Workload Identity is the recommended way of accessing Google Cloud APIs from pods.
 * // https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity
 * const myaccount = new gcp.serviceaccount.Account("myaccount", {
 *     accountId: "myaccount",
 *     displayName: "My Service Account",
 * });
 * const mykey = new gcp.serviceaccount.Key("mykey", {serviceAccountId: myaccount.name});
 * const google_application_credentials = new kubernetes.index.Secret("google-application-credentials", {
 *     metadata: [{
 *         name: "google-application-credentials",
 *     }],
 *     data: {
 *         "credentials.json": std.base64decodeOutput({
 *             input: mykey.privateKey,
 *         }).result,
 *     },
 * });
 * ```
 *
 * ## Import
 *
 * This resource does not support import.
 */
class Key extends pulumi.CustomResource {
    /**
     * Get an existing Key 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 Key(name, state, { ...opts, id: id });
    }
    /**
     * Returns true if the given object is an instance of Key.  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'] === Key.__pulumiType;
    }
    constructor(name, argsOrState, opts) {
        let resourceInputs = {};
        opts = opts || {};
        if (opts.id) {
            const state = argsOrState;
            resourceInputs["keepers"] = state?.keepers;
            resourceInputs["keyAlgorithm"] = state?.keyAlgorithm;
            resourceInputs["name"] = state?.name;
            resourceInputs["privateKey"] = state?.privateKey;
            resourceInputs["privateKeyType"] = state?.privateKeyType;
            resourceInputs["publicKey"] = state?.publicKey;
            resourceInputs["publicKeyData"] = state?.publicKeyData;
            resourceInputs["publicKeyType"] = state?.publicKeyType;
            resourceInputs["serviceAccountId"] = state?.serviceAccountId;
            resourceInputs["validAfter"] = state?.validAfter;
            resourceInputs["validBefore"] = state?.validBefore;
        }
        else {
            const args = argsOrState;
            if (args?.serviceAccountId === undefined && !opts.urn) {
                throw new Error("Missing required property 'serviceAccountId'");
            }
            resourceInputs["keepers"] = args?.keepers;
            resourceInputs["keyAlgorithm"] = args?.keyAlgorithm;
            resourceInputs["privateKeyType"] = args?.privateKeyType;
            resourceInputs["publicKeyData"] = args?.publicKeyData;
            resourceInputs["publicKeyType"] = args?.publicKeyType;
            resourceInputs["serviceAccountId"] = args?.serviceAccountId;
            resourceInputs["name"] = undefined /*out*/;
            resourceInputs["privateKey"] = undefined /*out*/;
            resourceInputs["publicKey"] = undefined /*out*/;
            resourceInputs["validAfter"] = undefined /*out*/;
            resourceInputs["validBefore"] = undefined /*out*/;
        }
        opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
        const aliasOpts = { aliases: [{ type: "gcp:serviceAccount/key:Key" }] };
        opts = pulumi.mergeOptions(opts, aliasOpts);
        const secretOpts = { additionalSecretOutputs: ["privateKey"] };
        opts = pulumi.mergeOptions(opts, secretOpts);
        super(Key.__pulumiType, name, resourceInputs, opts);
    }
}
exports.Key = Key;
/** @internal */
Key.__pulumiType = 'gcp:serviceaccount/key:Key';
//# sourceMappingURL=key.js.map