UNPKG

@pulumi/gcp

Version:

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

226 lines • 7.94 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.ApiKey = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * The Apikeys Key resource * * ## Example Usage * * ### Android_key * A basic example of a android api keys key * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const primary = new gcp.projects.ApiKey("primary", { * name: "key", * displayName: "sample-key", * restrictions: { * androidKeyRestrictions: { * allowedApplications: [{ * packageName: "com.example.app123", * sha1Fingerprint: "1699466a142d4682a5f91b50fdf400f2358e2b0b", * }], * }, * apiTargets: [{ * service: "translate.googleapis.com", * methods: ["GET*"], * }], * }, * }); * ``` * ### Basic_key * A basic example of a api keys key * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const primary = new gcp.projects.ApiKey("primary", { * name: "key", * displayName: "sample-key", * restrictions: { * apiTargets: [{ * service: "translate.googleapis.com", * methods: ["GET*"], * }], * browserKeyRestrictions: { * allowedReferrers: [".*"], * }, * }, * }); * ``` * ### Ios_key * A basic example of a ios api keys key * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const primary = new gcp.projects.ApiKey("primary", { * name: "key", * displayName: "sample-key", * restrictions: { * apiTargets: [{ * service: "translate.googleapis.com", * methods: ["GET*"], * }], * iosKeyRestrictions: { * allowedBundleIds: ["com.google.app.macos"], * }, * }, * }); * ``` * ### Minimal_key * A minimal example of a api keys key * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const primary = new gcp.projects.ApiKey("primary", { * name: "key", * displayName: "sample-key", * }); * ``` * ### Server_key * A basic example of a server api keys key * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const primary = new gcp.projects.ApiKey("primary", { * name: "key", * displayName: "sample-key", * restrictions: { * apiTargets: [{ * service: "translate.googleapis.com", * methods: ["GET*"], * }], * serverKeyRestrictions: { * allowedIps: ["127.0.0.1"], * }, * }, * }); * ``` * ### Service_account_key * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const project = new gcp.organizations.Project("project", { * projectId: "app", * name: "app", * orgId: "123456789", * deletionPolicy: "DELETE", * }); * const keyServiceAccount = new gcp.serviceaccount.Account("key_service_account", { * accountId: "app", * project: project.projectId, * displayName: "Test Service Account", * }); * const primary = new gcp.projects.ApiKey("primary", { * name: "key", * displayName: "sample-key", * project: project.projectId, * serviceAccountEmail: keyServiceAccount.email, * }); * ``` * * ## Import * * Key can be imported using any of these accepted formats: * * `projects/{{project}}/locations/global/keys/{{name}}` * * `{{project}}/{{name}}` * * `{{name}}` * * When using the `pulumi import` command, Key can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:projects/apiKey:ApiKey default projects/{{project}}/locations/global/keys/{{name}} * $ pulumi import gcp:projects/apiKey:ApiKey default {{project}}/{{name}} * $ pulumi import gcp:projects/apiKey:ApiKey default {{name}} * ``` */ class ApiKey extends pulumi.CustomResource { /** * Get an existing ApiKey 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 ApiKey(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:projects/apiKey:ApiKey'; /** * Returns true if the given object is an instance of ApiKey. 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'] === ApiKey.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["displayName"] = state?.displayName; resourceInputs["keyString"] = state?.keyString; resourceInputs["name"] = state?.name; resourceInputs["project"] = state?.project; resourceInputs["restrictions"] = state?.restrictions; resourceInputs["serviceAccountEmail"] = state?.serviceAccountEmail; resourceInputs["uid"] = state?.uid; } else { const args = argsOrState; resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["displayName"] = args?.displayName; resourceInputs["name"] = args?.name; resourceInputs["project"] = args?.project; resourceInputs["restrictions"] = args?.restrictions; resourceInputs["serviceAccountEmail"] = args?.serviceAccountEmail; resourceInputs["keyString"] = undefined /*out*/; resourceInputs["uid"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["keyString"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(ApiKey.__pulumiType, name, resourceInputs, opts); } } exports.ApiKey = ApiKey; //# sourceMappingURL=apiKey.js.map