UNPKG

@pulumi/gcp

Version:

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

185 lines 6.15 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.ApiKey = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = 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"], * }, * }, * }); * ``` * * ## 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}} * ``` * * ```sh * $ pulumi import gcp:projects/apiKey:ApiKey default {{project}}/{{name}} * ``` * * ```sh * $ 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, Object.assign(Object.assign({}, opts), { id: id })); } /** * 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["displayName"] = state ? state.displayName : undefined; resourceInputs["keyString"] = state ? state.keyString : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["restrictions"] = state ? state.restrictions : undefined; resourceInputs["uid"] = state ? state.uid : undefined; } else { const args = argsOrState; resourceInputs["displayName"] = args ? args.displayName : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["restrictions"] = args ? args.restrictions : undefined; 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; /** @internal */ ApiKey.__pulumiType = 'gcp:projects/apiKey:ApiKey'; //# sourceMappingURL=apiKey.js.map