UNPKG

@pulumi/gcp

Version:

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

357 lines • 16 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.Instance = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * A Google Cloud Redis instance. * * To get more information about Instance, see: * * * [API documentation](https://cloud.google.com/memorystore/docs/redis/reference/rest/v1/projects.locations.instances) * * How-to Guides * * [Official Documentation](https://cloud.google.com/memorystore/docs/redis/) * * ## Example Usage * * ### Redis Instance Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const cache = new gcp.redis.Instance("cache", { * name: "memory-cache", * memorySizeGb: 1, * }); * ``` * ### Redis Instance Full * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * // This example assumes this network already exists. * // The API creates a tenant network per network authorized for a * // Redis instance and that network is not deleted when the user-created * // network (authorized_network) is deleted, so this prevents issues * // with tenant network quota. * // If this network hasn't been created and you are using this example in your * // config, add an additional network resource or change * // this from "data"to "resource" * const redis_network = gcp.compute.getNetwork({ * name: "redis-test-network", * }); * const cache = new gcp.redis.Instance("cache", { * name: "ha-memory-cache", * tier: "STANDARD_HA", * memorySizeGb: 1, * locationId: "us-central1-a", * alternativeLocationId: "us-central1-f", * authorizedNetwork: redis_network.then(redis_network => redis_network.id), * redisVersion: "REDIS_4_0", * displayName: "Test Instance", * reservedIpRange: "192.168.0.0/29", * labels: { * my_key: "my_val", * other_key: "other_val", * }, * maintenancePolicy: { * weeklyMaintenanceWindows: [{ * day: "TUESDAY", * startTime: { * hours: 0, * minutes: 30, * seconds: 0, * nanos: 0, * }, * }], * }, * }); * ``` * ### Redis Instance Full With Persistence Config * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const cache_persis = new gcp.redis.Instance("cache-persis", { * name: "ha-memory-cache-persis", * tier: "STANDARD_HA", * memorySizeGb: 1, * locationId: "us-central1-a", * alternativeLocationId: "us-central1-f", * persistenceConfig: { * persistenceMode: "RDB", * rdbSnapshotPeriod: "TWELVE_HOURS", * }, * }); * ``` * ### Redis Instance Private Service * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * // This example assumes this network already exists. * // The API creates a tenant network per network authorized for a * // Redis instance and that network is not deleted when the user-created * // network (authorized_network) is deleted, so this prevents issues * // with tenant network quota. * // If this network hasn't been created and you are using this example in your * // config, add an additional network resource or change * // this from "data"to "resource" * const redis_network = new gcp.compute.Network("redis-network", {name: "redis-test-network"}); * const serviceRange = new gcp.compute.GlobalAddress("service_range", { * name: "address", * purpose: "VPC_PEERING", * addressType: "INTERNAL", * prefixLength: 16, * network: redis_network.id, * }); * const privateServiceConnection = new gcp.servicenetworking.Connection("private_service_connection", { * network: redis_network.id, * service: "servicenetworking.googleapis.com", * reservedPeeringRanges: [serviceRange.name], * }); * const cache = new gcp.redis.Instance("cache", { * name: "private-cache", * tier: "STANDARD_HA", * memorySizeGb: 1, * locationId: "us-central1-a", * alternativeLocationId: "us-central1-f", * authorizedNetwork: redis_network.id, * connectMode: "PRIVATE_SERVICE_ACCESS", * redisVersion: "REDIS_4_0", * displayName: "Test Instance", * }, { * dependsOn: [privateServiceConnection], * }); * ``` * ### Redis Instance Mrr * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * // This example assumes this network already exists. * // The API creates a tenant network per network authorized for a * // Redis instance and that network is not deleted when the user-created * // network (authorized_network) is deleted, so this prevents issues * // with tenant network quota. * // If this network hasn't been created and you are using this example in your * // config, add an additional network resource or change * // this from "data"to "resource" * const redis_network = gcp.compute.getNetwork({ * name: "redis-test-network", * }); * const cache = new gcp.redis.Instance("cache", { * name: "mrr-memory-cache", * tier: "STANDARD_HA", * memorySizeGb: 5, * locationId: "us-central1-a", * alternativeLocationId: "us-central1-f", * authorizedNetwork: redis_network.then(redis_network => redis_network.id), * redisVersion: "REDIS_6_X", * displayName: "Terraform Test Instance", * reservedIpRange: "192.168.0.0/28", * replicaCount: 5, * readReplicasMode: "READ_REPLICAS_ENABLED", * labels: { * my_key: "my_val", * other_key: "other_val", * }, * }); * ``` * ### Redis Instance Cmek * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const redisKeyring = new gcp.kms.KeyRing("redis_keyring", { * name: "redis-keyring", * location: "us-central1", * }); * const redisKey = new gcp.kms.CryptoKey("redis_key", { * name: "redis-key", * keyRing: redisKeyring.id, * }); * // This example assumes this network already exists. * // The API creates a tenant network per network authorized for a * // Redis instance and that network is not deleted when the user-created * // network (authorized_network) is deleted, so this prevents issues * // with tenant network quota. * // If this network hasn't been created and you are using this example in your * // config, add an additional network resource or change * // this from "data"to "resource" * const redis_network = gcp.compute.getNetwork({ * name: "redis-test-network", * }); * const cache = new gcp.redis.Instance("cache", { * name: "cmek-memory-cache", * tier: "STANDARD_HA", * memorySizeGb: 1, * locationId: "us-central1-a", * alternativeLocationId: "us-central1-f", * authorizedNetwork: redis_network.then(redis_network => redis_network.id), * redisVersion: "REDIS_6_X", * displayName: "Terraform Test Instance", * reservedIpRange: "192.168.0.0/29", * labels: { * my_key: "my_val", * other_key: "other_val", * }, * customerManagedKey: redisKey.id, * }); * ``` * * ## Import * * Instance can be imported using any of these accepted formats: * * * `projects/{{project}}/locations/{{region}}/instances/{{name}}` * * * `{{project}}/{{region}}/{{name}}` * * * `{{region}}/{{name}}` * * * `{{name}}` * * When using the `pulumi import` command, Instance can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:redis/instance:Instance default projects/{{project}}/locations/{{region}}/instances/{{name}} * ``` * * ```sh * $ pulumi import gcp:redis/instance:Instance default {{project}}/{{region}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:redis/instance:Instance default {{region}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:redis/instance:Instance default {{name}} * ``` */ class Instance extends pulumi.CustomResource { /** * Get an existing Instance 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 Instance(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Instance. 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'] === Instance.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["alternativeLocationId"] = state ? state.alternativeLocationId : undefined; resourceInputs["authEnabled"] = state ? state.authEnabled : undefined; resourceInputs["authString"] = state ? state.authString : undefined; resourceInputs["authorizedNetwork"] = state ? state.authorizedNetwork : undefined; resourceInputs["connectMode"] = state ? state.connectMode : undefined; resourceInputs["createTime"] = state ? state.createTime : undefined; resourceInputs["currentLocationId"] = state ? state.currentLocationId : undefined; resourceInputs["customerManagedKey"] = state ? state.customerManagedKey : undefined; resourceInputs["displayName"] = state ? state.displayName : undefined; resourceInputs["effectiveLabels"] = state ? state.effectiveLabels : undefined; resourceInputs["host"] = state ? state.host : undefined; resourceInputs["labels"] = state ? state.labels : undefined; resourceInputs["locationId"] = state ? state.locationId : undefined; resourceInputs["maintenancePolicy"] = state ? state.maintenancePolicy : undefined; resourceInputs["maintenanceSchedules"] = state ? state.maintenanceSchedules : undefined; resourceInputs["maintenanceVersion"] = state ? state.maintenanceVersion : undefined; resourceInputs["memorySizeGb"] = state ? state.memorySizeGb : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["nodes"] = state ? state.nodes : undefined; resourceInputs["persistenceConfig"] = state ? state.persistenceConfig : undefined; resourceInputs["persistenceIamIdentity"] = state ? state.persistenceIamIdentity : undefined; resourceInputs["port"] = state ? state.port : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["pulumiLabels"] = state ? state.pulumiLabels : undefined; resourceInputs["readEndpoint"] = state ? state.readEndpoint : undefined; resourceInputs["readEndpointPort"] = state ? state.readEndpointPort : undefined; resourceInputs["readReplicasMode"] = state ? state.readReplicasMode : undefined; resourceInputs["redisConfigs"] = state ? state.redisConfigs : undefined; resourceInputs["redisVersion"] = state ? state.redisVersion : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["replicaCount"] = state ? state.replicaCount : undefined; resourceInputs["reservedIpRange"] = state ? state.reservedIpRange : undefined; resourceInputs["secondaryIpRange"] = state ? state.secondaryIpRange : undefined; resourceInputs["serverCaCerts"] = state ? state.serverCaCerts : undefined; resourceInputs["tier"] = state ? state.tier : undefined; resourceInputs["transitEncryptionMode"] = state ? state.transitEncryptionMode : undefined; } else { const args = argsOrState; if ((!args || args.memorySizeGb === undefined) && !opts.urn) { throw new Error("Missing required property 'memorySizeGb'"); } resourceInputs["alternativeLocationId"] = args ? args.alternativeLocationId : undefined; resourceInputs["authEnabled"] = args ? args.authEnabled : undefined; resourceInputs["authorizedNetwork"] = args ? args.authorizedNetwork : undefined; resourceInputs["connectMode"] = args ? args.connectMode : undefined; resourceInputs["customerManagedKey"] = args ? args.customerManagedKey : undefined; resourceInputs["displayName"] = args ? args.displayName : undefined; resourceInputs["labels"] = args ? args.labels : undefined; resourceInputs["locationId"] = args ? args.locationId : undefined; resourceInputs["maintenancePolicy"] = args ? args.maintenancePolicy : undefined; resourceInputs["maintenanceVersion"] = args ? args.maintenanceVersion : undefined; resourceInputs["memorySizeGb"] = args ? args.memorySizeGb : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["persistenceConfig"] = args ? args.persistenceConfig : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["readReplicasMode"] = args ? args.readReplicasMode : undefined; resourceInputs["redisConfigs"] = args ? args.redisConfigs : undefined; resourceInputs["redisVersion"] = args ? args.redisVersion : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["replicaCount"] = args ? args.replicaCount : undefined; resourceInputs["reservedIpRange"] = args ? args.reservedIpRange : undefined; resourceInputs["secondaryIpRange"] = args ? args.secondaryIpRange : undefined; resourceInputs["tier"] = args ? args.tier : undefined; resourceInputs["transitEncryptionMode"] = args ? args.transitEncryptionMode : undefined; resourceInputs["authString"] = undefined /*out*/; resourceInputs["createTime"] = undefined /*out*/; resourceInputs["currentLocationId"] = undefined /*out*/; resourceInputs["effectiveLabels"] = undefined /*out*/; resourceInputs["host"] = undefined /*out*/; resourceInputs["maintenanceSchedules"] = undefined /*out*/; resourceInputs["nodes"] = undefined /*out*/; resourceInputs["persistenceIamIdentity"] = undefined /*out*/; resourceInputs["port"] = undefined /*out*/; resourceInputs["pulumiLabels"] = undefined /*out*/; resourceInputs["readEndpoint"] = undefined /*out*/; resourceInputs["readEndpointPort"] = undefined /*out*/; resourceInputs["serverCaCerts"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["authString", "effectiveLabels", "pulumiLabels"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Instance.__pulumiType, name, resourceInputs, opts); } } exports.Instance = Instance; /** @internal */ Instance.__pulumiType = 'gcp:redis/instance:Instance'; //# sourceMappingURL=instance.js.map