UNPKG

@pulumi/gcp

Version:

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

274 lines (273 loc) • 9.28 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * 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}} * ``` * * ```sh * $ pulumi import gcp:projects/apiKey:ApiKey default {{project}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:projects/apiKey:ApiKey default {{name}} * ``` */ export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: ApiKeyState, opts?: pulumi.CustomResourceOptions): 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: any): obj is ApiKey; /** * Human-readable display name of this API key. Modifiable by user. */ readonly displayName: pulumi.Output<string | undefined>; /** * Output only. An encrypted and signed value held by this key. This field can be accessed only through the `GetKeyString` method. */ readonly keyString: pulumi.Output<string>; /** * The resource name of the key. The name must be unique within the project, must conform with RFC-1034, is restricted to lower-cased letters, and has a maximum length of 63 characters. In another word, the name must match the regular expression: `a-z?`. * * * * - - - */ readonly name: pulumi.Output<string>; /** * The project for the resource */ readonly project: pulumi.Output<string>; /** * Key restrictions. */ readonly restrictions: pulumi.Output<outputs.projects.ApiKeyRestrictions | undefined>; /** * The email of the service account the key is bound to. If this field is specified, the key is a service account bound key and auth enabled. See [Documentation](https://cloud.devsite.corp.google.com/docs/authentication/api-keys?#api-keys-bound-sa) for more details. */ readonly serviceAccountEmail: pulumi.Output<string | undefined>; /** * Output only. Unique id in UUID4 format. */ readonly uid: pulumi.Output<string>; /** * Create a ApiKey resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args?: ApiKeyArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering ApiKey resources. */ export interface ApiKeyState { /** * Human-readable display name of this API key. Modifiable by user. */ displayName?: pulumi.Input<string>; /** * Output only. An encrypted and signed value held by this key. This field can be accessed only through the `GetKeyString` method. */ keyString?: pulumi.Input<string>; /** * The resource name of the key. The name must be unique within the project, must conform with RFC-1034, is restricted to lower-cased letters, and has a maximum length of 63 characters. In another word, the name must match the regular expression: `a-z?`. * * * * - - - */ name?: pulumi.Input<string>; /** * The project for the resource */ project?: pulumi.Input<string>; /** * Key restrictions. */ restrictions?: pulumi.Input<inputs.projects.ApiKeyRestrictions>; /** * The email of the service account the key is bound to. If this field is specified, the key is a service account bound key and auth enabled. See [Documentation](https://cloud.devsite.corp.google.com/docs/authentication/api-keys?#api-keys-bound-sa) for more details. */ serviceAccountEmail?: pulumi.Input<string>; /** * Output only. Unique id in UUID4 format. */ uid?: pulumi.Input<string>; } /** * The set of arguments for constructing a ApiKey resource. */ export interface ApiKeyArgs { /** * Human-readable display name of this API key. Modifiable by user. */ displayName?: pulumi.Input<string>; /** * The resource name of the key. The name must be unique within the project, must conform with RFC-1034, is restricted to lower-cased letters, and has a maximum length of 63 characters. In another word, the name must match the regular expression: `a-z?`. * * * * - - - */ name?: pulumi.Input<string>; /** * The project for the resource */ project?: pulumi.Input<string>; /** * Key restrictions. */ restrictions?: pulumi.Input<inputs.projects.ApiKeyRestrictions>; /** * The email of the service account the key is bound to. If this field is specified, the key is a service account bound key and auth enabled. See [Documentation](https://cloud.devsite.corp.google.com/docs/authentication/api-keys?#api-keys-bound-sa) for more details. */ serviceAccountEmail?: pulumi.Input<string>; }