@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
147 lines • 6.23 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** 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.core.v1.Secret("google-application-credentials", {
* metadata: {
* name: "google-application-credentials",
* },
* data: {
* "credentials.json": std.base64decodeOutput({
* input: mykey.privateKey,
* }).apply(invoke => invoke.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, Object.assign(Object.assign({}, 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 ? state.keepers : undefined;
resourceInputs["keyAlgorithm"] = state ? state.keyAlgorithm : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["privateKey"] = state ? state.privateKey : undefined;
resourceInputs["privateKeyType"] = state ? state.privateKeyType : undefined;
resourceInputs["publicKey"] = state ? state.publicKey : undefined;
resourceInputs["publicKeyData"] = state ? state.publicKeyData : undefined;
resourceInputs["publicKeyType"] = state ? state.publicKeyType : undefined;
resourceInputs["serviceAccountId"] = state ? state.serviceAccountId : undefined;
resourceInputs["validAfter"] = state ? state.validAfter : undefined;
resourceInputs["validBefore"] = state ? state.validBefore : undefined;
}
else {
const args = argsOrState;
if ((!args || args.serviceAccountId === undefined) && !opts.urn) {
throw new Error("Missing required property 'serviceAccountId'");
}
resourceInputs["keepers"] = args ? args.keepers : undefined;
resourceInputs["keyAlgorithm"] = args ? args.keyAlgorithm : undefined;
resourceInputs["privateKeyType"] = args ? args.privateKeyType : undefined;
resourceInputs["publicKeyData"] = args ? args.publicKeyData : undefined;
resourceInputs["publicKeyType"] = args ? args.publicKeyType : undefined;
resourceInputs["serviceAccountId"] = args ? args.serviceAccountId : undefined;
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