...
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 = "ha-memory-cache"
20 tier = "STANDARD_HA"
21 memory_size_gb = 1
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_4_0"
29 display_name = "Terraform Test Instance"
30 reserved_ip_range = "192.168.0.0/29"
31
32 labels = {
33 my_key = "my_val"
34 other_key = "other_val"
35 }
36
37 maintenance_policy {
38 weekly_maintenance_window {
39 day = "TUESDAY"
40 start_time {
41 hours = 0
42 minutes = 30
43 seconds = 0
44 nanos = 0
45 }
46 }
47 }
48}
49
50// This example assumes this network already exists.
51// The API creates a tenant network per network authorized for a
52// Redis instance and that network is not deleted when the user-created
53// network (authorized_network) is deleted, so this prevents issues
54// with tenant network quota.
55// If this network hasn't been created and you are using this example in your
56// config, add an additional network resource or change
57// this from "data"to "resource"
58data "google_compute_network" "redis-network" {
59 name = "redis-test-network"
60}
61```
View as plain text