@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
181 lines • 7.56 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Key = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
* Creates and manages service account keys, which allow the use of a service account with Google Cloud.
*
* > **Warning**: This resource persists a sensitive credential in plaintext in the remote state used by Terraform.
* Please take appropriate measures to protect your remote state.
*
* * [API documentation](https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts.keys)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/iam/docs/creating-managing-service-account-keys)
*
* ## 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 });
}
/** @internal */
static __pulumiType = 'gcp:serviceaccount/key:Key';
/**
* 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["deletionPolicy"] = state?.deletionPolicy;
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["deletionPolicy"] = args?.deletionPolicy;
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;
//# sourceMappingURL=key.js.map