Google Memcache Instance

This page shows how to write Terraform for Memcache Instance and write them securely.

google_memcache_instance (Terraform)

The Instance in Memcache can be configured in Terraform with the resource name google_memcache_instance. The following sections describe 2 examples of how to use the resource and its parameters.

Example Usage from GitHub

main.tf#L17
resource "google_memcache_instance" "self" {
  depends_on         = [module.enable_apis]
  provider           = google-beta
  project            = var.project
  zones              = var.zones
  name               = var.name
main.tf#L17
resource "google_memcache_instance" "self" {
  depends_on         = [module.enable_apis]
  provider           = google-beta
  project            = var.project
  zones              = var.zones
  name               = var.name

Review your Terraform file for Google best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

Parameters

The following arguments are supported:

  • name - (Required) The resource name of the instance.

  • node_count - (Required) Number of nodes in the memcache instance.

  • node_config - (Required) Configuration for memcache nodes. Structure is documented below.

The node_config block supports:

  • cpu_count - (Required) Number of CPUs per node.

  • memory_size_mb - (Required) Memory size in Mebibytes for each memcache node.


  • display_name - (Optional) A user-visible name for the instance.

  • labels - (Optional) Resource labels to represent user-provided metadata.

  • zones - (Optional) Zones where memcache nodes should be provisioned. If not provided, all zones will be used.

  • authorized_network - (Optional) The full name of the GCE network to connect the instance to. If not provided, 'default' will be used.

  • memcache_version - (Optional) 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_parameters - (Optional) User-specified parameters for this memcache instance. Structure is documented below.

  • region - (Optional) The region of the Memcache instance. If it is not provided, the provider region is used.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

The memcache_parameters block supports:

  • id - This is a unique ID associated with this set of parameters.

  • params - (Optional) User-defined set of parameters to use in the memcache process.

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format projects/[[project]]/locations/[[region]]/instances/[[name]]

  • memcache_nodes - Additional information about the instance state, if available. Structure is documented below.

  • create_time - Creation timestamp in RFC3339 text format.

  • discovery_endpoint - Endpoint for Discovery API

  • memcache_full_version - The full version of memcached server running on this instance.

The `memcache_nodes` block contains:
  • node_id - Identifier of the Memcached node. The node id does not include project or location like the Memcached instance name.

  • zone - Location (GCP Zone) for the Memcached node.

  • port - The port number of the Memcached server on this node.

  • host - Hostname or IP address of the Memcached node used by the clients to connect to the Memcached server on this node.

  • state - Current state of the Memcached node.

Explanation in Terraform Registry

A Google Cloud Memcache instance. To get more information about Instance, see:

Frequently asked questions

What is Google Memcache Instance?

Google Memcache Instance is a resource for Memcache of Google Cloud Platform. Settings can be wrote in Terraform.

Where can I find the example code for the Google Memcache Instance?

For Terraform, the terraform-google-modules/terraform-google-memorystore and jpushkar/Terraform-GCP-Memorystore source code examples are useful. See the Terraform Example section for further details.

security-icon

Automate config file reviews on your commits

Fix issues in your infrastructure as code with auto-generated patches.