UNPKG

@pulumi/gcp

Version:

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

154 lines 5.58 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! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.getKMSSecretCiphertextOutput = exports.getKMSSecretCiphertext = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * !> **Warning:** This data source is deprecated. Use the `gcp.kms.SecretCiphertext` **resource** instead. * * This data source allows you to encrypt data with Google Cloud KMS and use the * ciphertext within your resource definitions. * * For more information see * [the official documentation](https://cloud.google.com/kms/docs/encrypt-decrypt). * * > **NOTE:** Using this data source 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, encrypt some sensitive information and use the encrypted data in your resource definitions: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const myPassword = gcp.kms.getKMSSecretCiphertext({ * cryptoKey: myCryptoKey.id, * plaintext: "my-secret-password", * }); * const instance = new gcp.compute.Instance("instance", { * networkInterfaces: [{ * accessConfigs: [{}], * network: "default", * }], * name: "test", * machineType: "e2-medium", * zone: "us-central1-a", * bootDisk: { * initializeParams: { * image: "debian-cloud/debian-11", * }, * }, * metadata: { * password: myPassword.then(myPassword => myPassword.ciphertext), * }, * }); * ``` * * The resulting instance can then access the encrypted password from its metadata * and decrypt it, e.g. using the [Cloud SDK](https://cloud.google.com/sdk/gcloud/reference/kms/decrypt)): */ function getKMSSecretCiphertext(args, opts) { opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {}); return pulumi.runtime.invoke("gcp:kms/getKMSSecretCiphertext:getKMSSecretCiphertext", { "cryptoKey": args.cryptoKey, "plaintext": args.plaintext, }, opts); } exports.getKMSSecretCiphertext = getKMSSecretCiphertext; /** * !> **Warning:** This data source is deprecated. Use the `gcp.kms.SecretCiphertext` **resource** instead. * * This data source allows you to encrypt data with Google Cloud KMS and use the * ciphertext within your resource definitions. * * For more information see * [the official documentation](https://cloud.google.com/kms/docs/encrypt-decrypt). * * > **NOTE:** Using this data source 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, encrypt some sensitive information and use the encrypted data in your resource definitions: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const myPassword = gcp.kms.getKMSSecretCiphertext({ * cryptoKey: myCryptoKey.id, * plaintext: "my-secret-password", * }); * const instance = new gcp.compute.Instance("instance", { * networkInterfaces: [{ * accessConfigs: [{}], * network: "default", * }], * name: "test", * machineType: "e2-medium", * zone: "us-central1-a", * bootDisk: { * initializeParams: { * image: "debian-cloud/debian-11", * }, * }, * metadata: { * password: myPassword.then(myPassword => myPassword.ciphertext), * }, * }); * ``` * * The resulting instance can then access the encrypted password from its metadata * and decrypt it, e.g. using the [Cloud SDK](https://cloud.google.com/sdk/gcloud/reference/kms/decrypt)): */ function getKMSSecretCiphertextOutput(args, opts) { opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts || {}); return pulumi.runtime.invokeOutput("gcp:kms/getKMSSecretCiphertext:getKMSSecretCiphertext", { "cryptoKey": args.cryptoKey, "plaintext": args.plaintext, }, opts); } exports.getKMSSecretCiphertextOutput = getKMSSecretCiphertextOutput; //# sourceMappingURL=getKMSSecretCiphertext.js.map