Instance class

A Google Cloud Memcache instance.

To get more information about Instance, see:

Example Usage

Memcache Instance Basic

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
// Memcache 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 memcacheNetwork = new gcp.compute.Network("memcache_network", {name: "test-network"});
const serviceRange = new gcp.compute.GlobalAddress("service_range", {
    name: "address",
    purpose: "VPC_PEERING",
    addressType: "INTERNAL",
    prefixLength: 16,
    network: memcacheNetwork.id,
});
const privateServiceConnection = new gcp.servicenetworking.Connection("private_service_connection", {
    network: memcacheNetwork.id,
    service: "servicenetworking.googleapis.com",
    reservedPeeringRanges: [serviceRange.name],
});
const instance = new gcp.memcache.Instance("instance", {
    name: "test-instance",
    authorizedNetwork: privateServiceConnection.network,
    deletionProtection: false,
    labels: {
        env: "test",
    },
    nodeConfig: {
        cpuCount: 1,
        memorySizeMb: 1024,
    },
    nodeCount: 1,
    memcacheVersion: "MEMCACHE_1_5",
    maintenancePolicy: {
        weeklyMaintenanceWindows: [{
            day: "SATURDAY",
            duration: "14400s",
            startTime: {
                hours: 0,
                minutes: 30,
                seconds: 0,
                nanos: 0,
            },
        }],
    },
});
import pulumi
import pulumi_gcp as gcp

# This example assumes this network already exists.
# The API creates a tenant network per network authorized for a
# Memcache 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"
memcache_network = gcp.compute.Network("memcache_network", name="test-network")
service_range = gcp.compute.GlobalAddress("service_range",
    name="address",
    purpose="VPC_PEERING",
    address_type="INTERNAL",
    prefix_length=16,
    network=memcache_network.id)
private_service_connection = gcp.servicenetworking.Connection("private_service_connection",
    network=memcache_network.id,
    service="servicenetworking.googleapis.com",
    reserved_peering_ranges=[service_range.name])
instance = gcp.memcache.Instance("instance",
    name="test-instance",
    authorized_network=private_service_connection.network,
    deletion_protection=False,
    labels={
        "env": "test",
    },
    node_config={
        "cpu_count": 1,
        "memory_size_mb": 1024,
    },
    node_count=1,
    memcache_version="MEMCACHE_1_5",
    maintenance_policy={
        "weekly_maintenance_windows": [{
            "day": "SATURDAY",
            "duration": "14400s",
            "start_time": {
                "hours": 0,
                "minutes": 30,
                "seconds": 0,
                "nanos": 0,
            },
        }],
    })
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() =>
{
    // This example assumes this network already exists.
    // The API creates a tenant network per network authorized for a
    // Memcache 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"
    var memcacheNetwork = new Gcp.Compute.Network("memcache_network", new()
    {
        Name = "test-network",
    });

    var serviceRange = new Gcp.Compute.GlobalAddress("service_range", new()
    {
        Name = "address",
        Purpose = "VPC_PEERING",
        AddressType = "INTERNAL",
        PrefixLength = 16,
        Network = memcacheNetwork.Id,
    });

    var privateServiceConnection = new Gcp.ServiceNetworking.Connection("private_service_connection", new()
    {
        Network = memcacheNetwork.Id,
        Service = "servicenetworking.googleapis.com",
        ReservedPeeringRanges = new[]
        {
            serviceRange.Name,
        },
    });

    var instance = new Gcp.Memcache.Instance("instance", new()
    {
        Name = "test-instance",
        AuthorizedNetwork = privateServiceConnection.Network,
        DeletionProtection = false,
        Labels =
        {
            { "env", "test" },
        },
        NodeConfig = new Gcp.Memcache.Inputs.InstanceNodeConfigArgs
        {
            CpuCount = 1,
            MemorySizeMb = 1024,
        },
        NodeCount = 1,
        MemcacheVersion = "MEMCACHE_1_5",
        MaintenancePolicy = new Gcp.Memcache.Inputs.InstanceMaintenancePolicyArgs
        {
            WeeklyMaintenanceWindows = new[]
            {
                new Gcp.Memcache.Inputs.InstanceMaintenancePolicyWeeklyMaintenanceWindowArgs
                {
                    Day = "SATURDAY",
                    Duration = "14400s",
                    StartTime = new Gcp.Memcache.Inputs.InstanceMaintenancePolicyWeeklyMaintenanceWindowStartTimeArgs
                    {
                        Hours = 0,
                        Minutes = 30,
                        Seconds = 0,
                        Nanos = 0,
                    },
                },
            },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/memcache"
	"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/servicenetworking"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// This example assumes this network already exists.
		// The API creates a tenant network per network authorized for a
		// Memcache 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"
		memcacheNetwork, err := compute.NewNetwork(ctx, "memcache_network", &compute.NetworkArgs{
			Name: pulumi.String("test-network"),
		})
		if err != nil {
			return err
		}
		serviceRange, err := compute.NewGlobalAddress(ctx, "service_range", &compute.GlobalAddressArgs{
			Name:         pulumi.String("address"),
			Purpose:      pulumi.String("VPC_PEERING"),
			AddressType:  pulumi.String("INTERNAL"),
			PrefixLength: pulumi.Int(16),
			Network:      memcacheNetwork.ID().ToIDOutput().ToStringOutput(),
		})
		if err != nil {
			return err
		}
		privateServiceConnection, err := servicenetworking.NewConnection(ctx, "private_service_connection", &servicenetworking.ConnectionArgs{
			Network: memcacheNetwork.ID().ToIDOutput().ToStringOutput(),
			Service: pulumi.String("servicenetworking.googleapis.com"),
			ReservedPeeringRanges: pulumi.StringArray{
				serviceRange.Name,
			},
		})
		if err != nil {
			return err
		}
		_, err = memcache.NewInstance(ctx, "instance", &memcache.InstanceArgs{
			Name:               pulumi.String("test-instance"),
			AuthorizedNetwork:  privateServiceConnection.Network,
			DeletionProtection: pulumi.Bool(false),
			Labels: pulumi.StringMap{
				"env": pulumi.String("test"),
			},
			NodeConfig: &memcache.InstanceNodeConfigArgs{
				CpuCount:     pulumi.Int(1),
				MemorySizeMb: pulumi.Int(1024),
			},
			NodeCount:       pulumi.Int(1),
			MemcacheVersion: pulumi.String("MEMCACHE_1_5"),
			MaintenancePolicy: &memcache.InstanceMaintenancePolicyArgs{
				WeeklyMaintenanceWindows: memcache.InstanceMaintenancePolicyWeeklyMaintenanceWindowArray{
					&memcache.InstanceMaintenancePolicyWeeklyMaintenanceWindowArgs{
						Day:      pulumi.String("SATURDAY"),
						Duration: pulumi.String("14400s"),
						StartTime: &memcache.InstanceMaintenancePolicyWeeklyMaintenanceWindowStartTimeArgs{
							Hours:   pulumi.Int(0),
							Minutes: pulumi.Int(30),
							Seconds: pulumi.Int(0),
							Nanos:   pulumi.Int(0),
						},
					},
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    gcp = {
      source = "pulumi/gcp"
    }
  }
}

// This example assumes this network already exists.
// The API creates a tenant network per network authorized for a
// Memcache 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"
resource "gcp_compute_network" "memcache_network" {
  name = "test-network"
}
resource "gcp_compute_globaladdress" "service_range" {
  name          = "address"
  purpose       = "VPC_PEERING"
  address_type  = "INTERNAL"
  prefix_length = 16
  network       = gcp_compute_network.memcache_network.id
}
resource "gcp_servicenetworking_connection" "private_service_connection" {
  network                 = gcp_compute_network.memcache_network.id
  service                 = "servicenetworking.googleapis.com"
  reserved_peering_ranges = [gcp_compute_globaladdress.service_range.name]
}
resource "gcp_memcache_instance" "instance" {
  name                = "test-instance"
  authorized_network  = gcp_servicenetworking_connection.private_service_connection.network
  deletion_protection = false
  labels = {
    "env" = "test"
  }
  node_config = {
    cpu_count      = 1
    memory_size_mb = 1024
  }
  node_count       = 1
  memcache_version = "MEMCACHE_1_5"
  maintenance_policy = {
    weekly_maintenance_windows = [{
      "day"      = "SATURDAY"
      "duration" = "14400s"
      "startTime" = {
        "hours"   = 0
        "minutes" = 30
        "seconds" = 0
        "nanos"   = 0
      }
    }]
  }
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.Network;
import com.pulumi.gcp.compute.NetworkArgs;
import com.pulumi.gcp.compute.GlobalAddress;
import com.pulumi.gcp.compute.GlobalAddressArgs;
import com.pulumi.gcp.servicenetworking.Connection;
import com.pulumi.gcp.servicenetworking.ConnectionArgs;
import com.pulumi.gcp.memcache.Instance;
import com.pulumi.gcp.memcache.InstanceArgs;
import com.pulumi.gcp.memcache.inputs.InstanceNodeConfigArgs;
import com.pulumi.gcp.memcache.inputs.InstanceMaintenancePolicyArgs;
import com.pulumi.gcp.memcache.inputs.InstanceMaintenancePolicyWeeklyMaintenanceWindowArgs;
import com.pulumi.gcp.memcache.inputs.InstanceMaintenancePolicyWeeklyMaintenanceWindowStartTimeArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        // This example assumes this network already exists.
        // The API creates a tenant network per network authorized for a
        // Memcache 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"
        var memcacheNetwork = new Network("memcacheNetwork", NetworkArgs.builder()
            .name("test-network")
            .build());

        var serviceRange = new GlobalAddress("serviceRange", GlobalAddressArgs.builder()
            .name("address")
            .purpose("VPC_PEERING")
            .addressType("INTERNAL")
            .prefixLength(16)
            .network(memcacheNetwork.id())
            .build());

        var privateServiceConnection = new Connection("privateServiceConnection", ConnectionArgs.builder()
            .network(memcacheNetwork.id())
            .service("servicenetworking.googleapis.com")
            .reservedPeeringRanges(serviceRange.name())
            .build());

        var instance = new Instance("instance", InstanceArgs.builder()
            .name("test-instance")
            .authorizedNetwork(privateServiceConnection.network())
            .deletionProtection(false)
            .labels(Map.of("env", "test"))
            .nodeConfig(InstanceNodeConfigArgs.builder()
                .cpuCount(1)
                .memorySizeMb(1024)
                .build())
            .nodeCount(1)
            .memcacheVersion("MEMCACHE_1_5")
            .maintenancePolicy(InstanceMaintenancePolicyArgs.builder()
                .weeklyMaintenanceWindows(InstanceMaintenancePolicyWeeklyMaintenanceWindowArgs.builder()
                    .day("SATURDAY")
                    .duration("14400s")
                    .startTime(InstanceMaintenancePolicyWeeklyMaintenanceWindowStartTimeArgs.builder()
                        .hours(0)
                        .minutes(30)
                        .seconds(0)
                        .nanos(0)
                        .build())
                    .build())
                .build())
            .build());

    }
}
resources:
  # This example assumes this network already exists.
  # // The API creates a tenant network per network authorized for a
  # // Memcache 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"
  memcacheNetwork:
    type: gcp:compute:Network
    name: memcache_network
    properties:
      name: test-network
  serviceRange:
    type: gcp:compute:GlobalAddress
    name: service_range
    properties:
      name: address
      purpose: VPC_PEERING
      addressType: INTERNAL
      prefixLength: 16
      network: ${memcacheNetwork.id}
  privateServiceConnection:
    type: gcp:servicenetworking:Connection
    name: private_service_connection
    properties:
      network: ${memcacheNetwork.id}
      service: servicenetworking.googleapis.com
      reservedPeeringRanges:
        - ${serviceRange.name}
  instance:
    type: gcp:memcache:Instance
    properties:
      name: test-instance
      authorizedNetwork: ${privateServiceConnection.network}
      deletionProtection: false
      labels:
        env: test
      nodeConfig:
        cpuCount: 1
        memorySizeMb: 1024
      nodeCount: 1
      memcacheVersion: MEMCACHE_1_5
      maintenancePolicy:
        weeklyMaintenanceWindows:
          - day: SATURDAY
            duration: 14400s
            startTime:
              hours: 0
              minutes: 30
              seconds: 0
              nanos: 0

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:

$ pulumi import gcp:memcache/instance:Instance default projects/{{project}}/locations/{{region}}/instances/{{name}}
$ pulumi import gcp:memcache/instance:Instance default {{project}}/{{region}}/{{name}}
$ pulumi import gcp:memcache/instance:Instance default {{region}}/{{name}}
$ pulumi import gcp:memcache/instance:Instance default {{name}}

Constructors

Instance(String name, {InstanceArgs? args, CustomResourceOptions? options})
Creates a new Instance. name The Pulumi resource name. args Arguments used to configure this Instance. The set of arguments for Instance. options Resource options controlling this resource's behavior.
Instance.reference(String urn)
Creates a typed reference to an existing Instance resource.

Properties

authorizedNetwork ↔ Output<String>
The full name of the GCE network to connect the instance to. If not provided, 'default' will be used.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
createTime ↔ Output<String>
Creation timestamp in RFC3339 text format.
latefinal
deletionPolicy ↔ Output<String>
Whether Terraform will be prevented from destroying the resource. Defaults to DELETE. When a 'terraform destroy' or 'pulumi up' would delete the resource, the command will fail if this field is set to "PREVENT" in Terraform state. When set to "ABANDON", the command will remove the resource from Terraform management without updating or deleting the resource in the API. When set to "DELETE", deleting the resource is allowed.
latefinal
deletionProtection ↔ Output<bool?>
Whether Terraform will be prevented from destroying the instance. When a terraform destroy or pulumi up would delete the instance, the command will fail if this field is not set to false in Terraform state. When the field is set to true or unset in Terraform state, a pulumi up or terraform destroy that would delete the instance will fail. When the field is set to false, deleting the instance is allowed.
latefinal
discoveryEndpoint ↔ Output<String>
Endpoint for Discovery API
latefinal
displayName ↔ Output<String>
A user-visible name for the instance.
latefinal
effectiveLabels ↔ Output<Map<String, String>>
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
labels ↔ Output<Map<String, String>?>
Resource labels to represent user-provided metadata.
latefinal
maintenancePolicy ↔ Output<InstanceMaintenancePolicy?>
Maintenance policy for an instance. Structure is documented below.
latefinal
maintenanceSchedules ↔ Output<List<InstanceMaintenanceSchedule>>
Output only. Published maintenance schedule. Structure is documented below.
latefinal
memcacheFullVersion ↔ Output<String>
The full version of memcached server running on this instance.
latefinal
memcacheNodes ↔ Output<List<InstanceMemcacheNode>>
Additional information about the instance state, if available. Structure is documented below.
latefinal
memcacheParameters ↔ Output<InstanceMemcacheParameters?>
User-specified parameters for this memcache instance. Structure is documented below.
latefinal
memcacheVersion ↔ Output<String?>
The major version of Memcached software. If not provided, latest supported version will be used. Currently the latest supported major version is MEMCACHE_1_5. The minor version will be automatically determined by our system based on the latest supported minor version. Default value is MEMCACHE_1_5. Possible values are: MEMCACHE_1_5, MEMCACHE_1_6_15.
latefinal
name ↔ Output<String>
The resource name of the instance.
latefinal
nodeConfig ↔ Output<InstanceNodeConfig>
Configuration for memcache nodes. Structure is documented below.
latefinal
nodeCount ↔ Output<int>
Number of nodes in the memcache instance.
latefinal
project ↔ Output<String>
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
latefinal
pulumiLabels ↔ Output<Map<String, String>>
The combination of labels configured directly on the resource and default labels configured on the provider.
latefinal
region ↔ Output<String>
The region of the Memcache instance. If it is not provided, the provider region is used.
latefinal
reservedIpRangeIds ↔ Output<List<String>?>
Contains the name of allocated IP address ranges associated with the private service access connection for example, "test-default" associated with IP range 10.0.0.0/29.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited
zones ↔ Output<List<String>>
Zones where memcache nodes should be provisioned. If not provided, all zones will be used.
latefinal

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {InstanceState? state, CustomResourceOptions? options}) → Instance
Gets an existing Instance resource's state with the given name and id.