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