@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
131 lines • 5.48 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.ProjectMetadata = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(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 });
}
/** @internal */
static __pulumiType = 'gcp:compute/projectMetadata:ProjectMetadata';
/**
* 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["deletionPolicy"] = state?.deletionPolicy;
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["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["metadata"] = args?.metadata;
resourceInputs["project"] = args?.project;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ProjectMetadata.__pulumiType, name, resourceInputs, opts);
}
}
exports.ProjectMetadata = ProjectMetadata;
//# sourceMappingURL=projectMetadata.js.map