UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

175 lines 6.77 kB
"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! *** 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.getKMSSecretOutput = exports.getKMSSecret = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * This data source allows you to use data encrypted with Google Cloud KMS * within your resource definitions. * * For more information see * [the official documentation](https://cloud.google.com/kms/docs/encrypt-decrypt). * * > **NOTE:** Using this data provider will allow you to conceal secret data within your * resource definitions, but it does not take care of protecting that data in the * logging output, plan output, or state output. Please take care to secure your secret * data outside of resource definitions. * * ## Example Usage * * First, create a KMS KeyRing and CryptoKey using the resource definitions: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const myKeyRing = new gcp.kms.KeyRing("my_key_ring", { * project: "my-project", * name: "my-key-ring", * location: "us-central1", * }); * const myCryptoKey = new gcp.kms.CryptoKey("my_crypto_key", { * name: "my-crypto-key", * keyRing: myKeyRing.id, * }); * ``` * * Next, use the [Cloud SDK](https://cloud.google.com/sdk/gcloud/reference/kms/encrypt) to encrypt some * sensitive information: * * Finally, reference the encrypted ciphertext in your resource definitions: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as random from "@pulumi/random"; * * const sqlUserPassword = gcp.kms.getKMSSecret({ * cryptoKey: myCryptoKey.id, * ciphertext: "CiQAqD+xX4SXOSziF4a8JYvq4spfAuWhhYSNul33H85HnVtNQW4SOgDu2UZ46dQCRFl5MF6ekabviN8xq+F+2035ZJ85B+xTYXqNf4mZs0RJitnWWuXlYQh6axnnJYu3kDU=", * }); * const dbNameSuffix = new random.index.Id("db_name_suffix", {byteLength: 4}); * const main = new gcp.sql.DatabaseInstance("main", { * name: `main-instance-${dbNameSuffix.hex}`, * databaseVersion: "MYSQL_5_7", * settings: { * tier: "db-f1-micro", * }, * }); * const users = new gcp.sql.User("users", { * name: "me", * instance: main.name, * host: "me.com", * password: sqlUserPassword.then(sqlUserPassword => sqlUserPassword.plaintext), * }); * ``` * * This will result in a Cloud SQL user being created with password `my-secret-password`. */ function getKMSSecret(args, opts) { opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {}); return pulumi.runtime.invoke("gcp:kms/getKMSSecret:getKMSSecret", { "additionalAuthenticatedData": args.additionalAuthenticatedData, "ciphertext": args.ciphertext, "cryptoKey": args.cryptoKey, }, opts); } exports.getKMSSecret = getKMSSecret; /** * This data source allows you to use data encrypted with Google Cloud KMS * within your resource definitions. * * For more information see * [the official documentation](https://cloud.google.com/kms/docs/encrypt-decrypt). * * > **NOTE:** Using this data provider will allow you to conceal secret data within your * resource definitions, but it does not take care of protecting that data in the * logging output, plan output, or state output. Please take care to secure your secret * data outside of resource definitions. * * ## Example Usage * * First, create a KMS KeyRing and CryptoKey using the resource definitions: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const myKeyRing = new gcp.kms.KeyRing("my_key_ring", { * project: "my-project", * name: "my-key-ring", * location: "us-central1", * }); * const myCryptoKey = new gcp.kms.CryptoKey("my_crypto_key", { * name: "my-crypto-key", * keyRing: myKeyRing.id, * }); * ``` * * Next, use the [Cloud SDK](https://cloud.google.com/sdk/gcloud/reference/kms/encrypt) to encrypt some * sensitive information: * * Finally, reference the encrypted ciphertext in your resource definitions: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as random from "@pulumi/random"; * * const sqlUserPassword = gcp.kms.getKMSSecret({ * cryptoKey: myCryptoKey.id, * ciphertext: "CiQAqD+xX4SXOSziF4a8JYvq4spfAuWhhYSNul33H85HnVtNQW4SOgDu2UZ46dQCRFl5MF6ekabviN8xq+F+2035ZJ85B+xTYXqNf4mZs0RJitnWWuXlYQh6axnnJYu3kDU=", * }); * const dbNameSuffix = new random.index.Id("db_name_suffix", {byteLength: 4}); * const main = new gcp.sql.DatabaseInstance("main", { * name: `main-instance-${dbNameSuffix.hex}`, * databaseVersion: "MYSQL_5_7", * settings: { * tier: "db-f1-micro", * }, * }); * const users = new gcp.sql.User("users", { * name: "me", * instance: main.name, * host: "me.com", * password: sqlUserPassword.then(sqlUserPassword => sqlUserPassword.plaintext), * }); * ``` * * This will result in a Cloud SQL user being created with password `my-secret-password`. */ function getKMSSecretOutput(args, opts) { opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {}); return pulumi.runtime.invokeOutput("gcp:kms/getKMSSecret:getKMSSecret", { "additionalAuthenticatedData": args.additionalAuthenticatedData, "ciphertext": args.ciphertext, "cryptoKey": args.cryptoKey, }, opts); } exports.getKMSSecretOutput = getKMSSecretOutput; //# sourceMappingURL=getKMSSecret.js.map