...
1/**
2 * Copyright 2022 Google LLC
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17```hcl
18resource "google_redis_instance" "cache" {
19 name = "mrr-memory-cache"
20 tier = "STANDARD_HA"
21 memory_size_gb = 5
22
23 location_id = "us-central1-a"
24 alternative_location_id = "us-central1-f"
25
26 authorized_network = data.google_compute_network.redis-network.id
27
28 redis_version = "REDIS_6_X"
29 display_name = "Terraform Test Instance"
30 reserved_ip_range = "192.168.0.0/28"
31 replica_count = 5
32 read_replicas_mode = "READ_REPLICAS_ENABLED"
33
34 labels = {
35 my_key = "my_val"
36 other_key = "other_val"
37 }
38}
39
40// This example assumes this network already exists.
41// The API creates a tenant network per network authorized for a
42// Redis instance and that network is not deleted when the user-created
43// network (authorized_network) is deleted, so this prevents issues
44// with tenant network quota.
45// If this network hasn't been created and you are using this example in your
46// config, add an additional network resource or change
47// this from "data"to "resource"
48data "google_compute_network" "redis-network" {
49 name = "redis-test-network"
50}
51```
View as plain text