forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredis_cluster_secondary.tf.tmpl
151 lines (135 loc) · 5.11 KB
/
redis_cluster_secondary.tf.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Primary cluster
resource "google_redis_cluster" "primary_cluster" {
name = "{{index $.Vars "primary_cluster_name"}}"
region = "us-east1"
psc_configs {
network = google_compute_network.consumer_net.id
}
// Settings that should match on primary and secondary clusters.
// If you define a setting here, ensure that the secondary clusters also define it with the same values.
// Please see https://cloud.google.com/memorystore/docs/cluster/about-cross-region-replication#settings_copied_from_the_primary_during_instance_creation for the complete list of such settings.
authorization_mode = "AUTH_MODE_DISABLED"
transit_encryption_mode = "TRANSIT_ENCRYPTION_MODE_DISABLED"
shard_count = 3
redis_configs = {
maxmemory-policy = "volatile-ttl"
}
node_type = "REDIS_HIGHMEM_MEDIUM"
persistence_config {
mode = "RDB"
rdb_config {
rdb_snapshot_period = "ONE_HOUR"
rdb_snapshot_start_time = "2024-10-02T15:01:23Z"
}
}
// Settings that can have different values on primary and secondary clusters.
// Please see https://cloud.google.com/memorystore/docs/cluster/about-cross-region-replication#override_allowed_during_instance_creation for the complete list of such settings.
zone_distribution_config {
mode = "MULTI_ZONE"
}
replica_count = 1
maintenance_policy {
weekly_maintenance_window {
day = "MONDAY"
start_time {
hours = 1
minutes = 0
seconds = 0
nanos = 0
}
}
}
deletion_protection_enabled = {{index $.Vars "primary_cluster_deletion_protection_enabled"}}
depends_on = [
google_network_connectivity_service_connection_policy.primary_cluster_region_scp
]
}
// Secondary cluster
resource "google_redis_cluster" "{{$.PrimaryResourceId}}" {
name = "{{index $.Vars "secondary_cluster_name"}}"
region = "europe-west1"
psc_configs {
network = google_compute_network.consumer_net.id
}
// Settings that should match on primary and secondary clusters.
// If you defined a setting here for primary, ensure the secondary clusters also define it with the same values.
// Please see https://cloud.google.com/memorystore/docs/cluster/about-cross-region-replication#settings_copied_from_the_primary_during_instance_creation for the complete list of such settings.
authorization_mode = "AUTH_MODE_DISABLED"
transit_encryption_mode = "TRANSIT_ENCRYPTION_MODE_DISABLED"
shard_count = 3
redis_configs = {
maxmemory-policy = "volatile-ttl"
}
node_type = "REDIS_HIGHMEM_MEDIUM"
persistence_config {
mode = "RDB"
rdb_config {
rdb_snapshot_period = "ONE_HOUR"
rdb_snapshot_start_time = "2024-10-02T15:01:23Z"
}
}
// Settings that can be different on primary and secondary clusters.
// Please see https://cloud.google.com/memorystore/docs/cluster/about-cross-region-replication#override_allowed_during_instance_creation for the complete list of such settings.
zone_distribution_config {
mode = "MULTI_ZONE"
}
replica_count = 2
maintenance_policy {
weekly_maintenance_window {
day = "WEDNESDAY"
start_time {
hours = 1
minutes = 0
seconds = 0
nanos = 0
}
}
}
deletion_protection_enabled = {{index $.Vars "secondary_cluster_deletion_protection_enabled"}}
// Cross cluster replication config
cross_cluster_replication_config {
cluster_role = "SECONDARY"
primary_cluster {
cluster = google_redis_cluster.primary_cluster.id
}
}
depends_on = [
google_network_connectivity_service_connection_policy.secondary_cluster_region_scp
]
}
resource "google_network_connectivity_service_connection_policy" "primary_cluster_region_scp" {
name = "{{index $.Vars "primary_cluster_policy_name"}}"
location = "us-east1"
service_class = "gcp-memorystore-redis"
description = "Primary cluster service connection policy"
network = google_compute_network.consumer_net.id
psc_config {
subnetworks = [google_compute_subnetwork.primary_cluster_consumer_subnet.id]
}
}
resource "google_compute_subnetwork" "primary_cluster_consumer_subnet" {
name = "{{index $.Vars "primary_cluster_subnet_name"}}"
ip_cidr_range = "10.0.1.0/29"
region = "us-east1"
network = google_compute_network.consumer_net.id
}
resource "google_network_connectivity_service_connection_policy" "secondary_cluster_region_scp" {
name = "{{index $.Vars "secondary_cluster_policy_name"}}"
location = "europe-west1"
service_class = "gcp-memorystore-redis"
description = "Secondary cluster service connection policy"
network = google_compute_network.consumer_net.id
psc_config {
subnetworks = [google_compute_subnetwork.secondary_cluster_consumer_subnet.id]
}
}
resource "google_compute_subnetwork" "secondary_cluster_consumer_subnet" {
name = "{{index $.Vars "secondary_cluster_subnet_name"}}"
ip_cidr_range = "10.0.2.0/29"
region = "europe-west1"
network = google_compute_network.consumer_net.id
}
resource "google_compute_network" "consumer_net" {
name = "{{index $.Vars "network_name"}}"
auto_create_subnetworks = false
}