1
+ resource "google_memorystore_instance_desired_user_created_connections" "{{$.PrimaryResourceId}}" {
2
+ name = "{{index $.Vars "instance_name"}}"
3
+ region = "us-central1"
4
+ desired_user_endpoints {
5
+ connections {
6
+ psc_connection {
7
+ psc_connection_id = google_compute_forwarding_rule.forwarding_rule1_network2.psc_connection_id
8
+ ip_address = google_compute_address.ip1_network2.address
9
+ forwarding_rule = google_compute_forwarding_rule.forwarding_rule1_network2.id
10
+ network = google_compute_network.network2.id
11
+ service_attachment = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[0].service_attachment
12
+ }
13
+ }
14
+ connections {
15
+ psc_connection {
16
+ psc_connection_id = google_compute_forwarding_rule.forwarding_rule2_network2.psc_connection_id
17
+ ip_address = google_compute_address.ip2_network2.address
18
+ forwarding_rule = google_compute_forwarding_rule.forwarding_rule2_network2.id
19
+ network = google_compute_network.network2.id
20
+ service_attachment = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[1].service_attachment
21
+ }
22
+ }
23
+ }
24
+ desired_user_endpoints {
25
+ connections {
26
+ psc_connection {
27
+ psc_connection_id = google_compute_forwarding_rule.forwarding_rule1_network2.psc_connection_id
28
+ ip_address = google_compute_address.ip1_network2.address
29
+ forwarding_rule = google_compute_forwarding_rule.forwarding_rule1_network2.id
30
+ network = google_compute_network.network2.id
31
+ service_attachment = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[0].service_attachment
32
+ }
33
+ }
34
+ connections {
35
+ psc_connection {
36
+ psc_connection_id = google_compute_forwarding_rule.forwarding_rule2_network2.psc_connection_id
37
+ ip_address = google_compute_address.ip2_network2.address
38
+ forwarding_rule = google_compute_forwarding_rule.forwarding_rule2_network2.id
39
+ network = google_compute_network.network2.id
40
+ service_attachment = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[1].service_attachment
41
+ }
42
+ }
43
+ }
44
+ }
45
+
46
+ resource "google_compute_forwarding_rule" "forwarding_rule1_network1" {
47
+ name = "{{index $.Vars "forwarding_rule1_network1_name"}}"
48
+ region = "us-central1"
49
+ ip_address = google_compute_address.ip1_network1.id
50
+ load_balancing_scheme = ""
51
+ network = google_compute_network.network1.id
52
+ target = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[0].service_attachment
53
+ }
54
+
55
+ resource "google_compute_forwarding_rule" "forwarding_rule2_network1" {
56
+ name = "{{index $.Vars "forwarding_rule2_network1_name"}}"
57
+ region = "us-central1"
58
+ ip_address = google_compute_address.ip2_network1.id
59
+ load_balancing_scheme = ""
60
+ network = google_compute_network.network1.id
61
+ target = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[1].service_attachment
62
+ }
63
+
64
+ resource "google_compute_address" "ip1_network1" {
65
+ name = "{{index $.Vars "ip1_network1_name"}}"
66
+ region = "us-central1"
67
+ subnetwork = google_compute_subnetwork.subnet_network1.id
68
+ address_type = "INTERNAL"
69
+ purpose = "GCE_ENDPOINT"
70
+ }
71
+
72
+ resource "google_compute_address" "ip2_network1" {
73
+ name = "{{index $.Vars "ip2_network1_name"}}"
74
+ region = "us-central1"
75
+ subnetwork = google_compute_subnetwork.subnet_network1.id
76
+ address_type = "INTERNAL"
77
+ purpose = "GCE_ENDPOINT"
78
+ }
79
+
80
+ resource "google_compute_subnetwork" "subnet_network1" {
81
+ name = "{{index $.Vars "subnet_network1_name"}}"
82
+ ip_cidr_range = "10.0.0.248/29"
83
+ region = "us-central1"
84
+ network = google_compute_network.network1.id
85
+ }
86
+
87
+ resource "google_compute_network" "network1" {
88
+ name = "{{index $.Vars "network1_name"}}"
89
+ auto_create_subnetworks = false
90
+ }
91
+
92
+ resource "google_compute_forwarding_rule" "forwarding_rule1_network2" {
93
+ name = "{{index $.Vars "forwarding_rule1_network2_name"}}"
94
+ region = "us-central1"
95
+ ip_address = google_compute_address.ip1_network2.id
96
+ load_balancing_scheme = ""
97
+ network = google_compute_network.network2.id
98
+ target = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[0].service_attachment
99
+ }
100
+
101
+ resource "google_compute_forwarding_rule" "forwarding_rule2_network2" {
102
+ name = "{{index $.Vars "forwarding_rule2_network2_name"}}"
103
+ region = "us-central1"
104
+ ip_address = google_compute_address.ip2_network2.id
105
+ load_balancing_scheme = ""
106
+ network = google_compute_network.network2.id
107
+ target = google_memorystore_instance.{{$.PrimaryResourceId}}.psc_attachment_details[1].service_attachment
108
+ }
109
+
110
+ resource "google_compute_address" "ip1_network2" {
111
+ name = "{{index $.Vars "ip1_network2_name"}}"
112
+ region = "us-central1"
113
+ subnetwork = google_compute_subnetwork.subnet_network2.id
114
+ address_type = "INTERNAL"
115
+ purpose = "GCE_ENDPOINT"
116
+ }
117
+
118
+ resource "google_compute_address" "ip2_network2" {
119
+ name = "{{index $.Vars "ip2_network2_name"}}"
120
+ region = "us-central1"
121
+ subnetwork = google_compute_subnetwork.subnet_network2.id
122
+ address_type = "INTERNAL"
123
+ purpose = "GCE_ENDPOINT"
124
+ }
125
+
126
+ //Valkey instance without endpoints
127
+ resource "google_memorystore_instance" "{{$.PrimaryResourceId}}" {
128
+ instance_id = "{{index $.Vars "instance_name"}}"
129
+ shard_count = 3
130
+ location = "us-central1"
131
+ deletion_protection_enabled = false
132
+ }
133
+
134
+ resource "google_compute_subnetwork" "subnet_network2" {
135
+ name = "{{index $.Vars "subnet_network2_name"}}"
136
+ ip_cidr_range = "10.0.0.248/29"
137
+ region = "us-central1"
138
+ network = google_compute_network.network2.id
139
+ }
140
+
141
+ resource "google_compute_network" "network2" {
142
+ name = "{{index $.Vars "network2_name"}}"
143
+ auto_create_subnetworks = false
144
+ }
145
+
146
+
147
+ data "google_project" "project" {
148
+ }
0 commit comments