UNPKG

@pulumi/gcp

Version:

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

106 lines 4.29 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.ProjectMetadata = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Authoritatively manages metadata common to all instances for a project in GCE. For more information see * [the official documentation](https://cloud.google.com/compute/docs/storing-retrieving-metadata) * and * [API](https://cloud.google.com/compute/docs/reference/latest/projects/setCommonInstanceMetadata). * * > **Note:** This resource manages all project-level metadata including project-level ssh keys. * Keys unset in config but set on the server will be removed. If you want to manage only single * key/value pairs within the project metadata rather than the entire set, then use * google_compute_project_metadata_item. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.compute.ProjectMetadata("default", {metadata: { * foo: "bar", * fizz: "buzz", * "13": "42", * }}); * ``` * * ### Adding An SSH Key * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * //A key set in project metadata is propagated to every instance in the project. * //This resource configuration is prone to causing frequent diffs as Google adds SSH Keys when the SSH Button is pressed in the console. * //It is better to use OS Login instead. * const mySshKey = new gcp.compute.ProjectMetadata("my_ssh_key", {metadata: { * "ssh-keys": ` dev:ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILg6UtHDNyMNAh0GjaytsJdrUxjtLy3APXqZfNZhvCeT dev * foo:ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILg6UtHDNyMNAh0GjaytsJdrUxjtLy3APXqZfNZhvCeT bar * `, * }}); * ``` * * ## Import * * Project metadata can be imported using the project ID: * * * `{{project_id}}` * * When using the `pulumi import` command, project metadata can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:compute/projectMetadata:ProjectMetadata default {{project_id}} * ``` */ class ProjectMetadata extends pulumi.CustomResource { /** * Get an existing ProjectMetadata 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 ProjectMetadata(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of ProjectMetadata. 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'] === ProjectMetadata.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["metadata"] = state?.metadata; resourceInputs["project"] = state?.project; } else { const args = argsOrState; if (args?.metadata === undefined && !opts.urn) { throw new Error("Missing required property 'metadata'"); } resourceInputs["metadata"] = args?.metadata; resourceInputs["project"] = args?.project; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(ProjectMetadata.__pulumiType, name, resourceInputs, opts); } } exports.ProjectMetadata = ProjectMetadata; /** @internal */ ProjectMetadata.__pulumiType = 'gcp:compute/projectMetadata:ProjectMetadata'; //# sourceMappingURL=projectMetadata.js.map