-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
64 lines (62 loc) · 2.48 KB
/
main.tf
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
module "alloydb_delhi" {
source = "GoogleCloudPlatform/alloy-db/google"
version = "~> 3.0"
cluster_id = "cluster-${var.region_delhi}-psc"
cluster_location = var.region_delhi
project_id = var.project_id
psc_enabled = true
psc_allowed_consumer_projects = [var.attachment_project_number]
cluster_encryption_key_name = google_kms_crypto_key.key_region_delhi.id
automated_backup_policy = {
location = var.region_delhi
backup_window = "1800s"
enabled = true
weekly_schedule = {
days_of_week = ["FRIDAY"],
start_times = ["2:00:00:00", ]
}
quantity_based_retention_count = 1
time_based_retention_count = null
labels = {
test = "alloydb-cluster-with-prim"
}
backup_encryption_key_name = google_kms_crypto_key.key_region_delhi.id
}
continuous_backup_recovery_window_days = 10
continuous_backup_encryption_key_name = google_kms_crypto_key.key_region_delhi.id
primary_instance = {
instance_id = "cluster-${var.region_delhi}-instance1-psc",
require_connectors = false
ssl_mode = "ALLOW_UNENCRYPTED_AND_ENCRYPTED"
}
read_pool_instance = [
{
instance_id = "cluster-${var.region_delhi}-r1-psc"
display_name = "cluster-${var.region_delhi}-r1-psc"
require_connectors = false
ssl_mode = "ALLOW_UNENCRYPTED_AND_ENCRYPTED"
}
]
depends_on = [
google_kms_crypto_key_iam_member.alloydb_sa_iam,
google_kms_crypto_key.key_region_delhi,
]
}
resource "google_compute_address" "psc_consumer_address" {
name = "psc-consumer-address"
project = var.attachment_project_id
region = var.region_delhi
subnetwork = google_compute_subnetwork.psc_subnet.name
address_type = "INTERNAL"
address = "10.2.0.10"
}
resource "google_compute_forwarding_rule" "psc_fwd_rule_consumer" {
name = "psc-fwd-rule-consumer-endpoint"
region = var.region_delhi
project = var.attachment_project_id
target = module.alloydb_delhi.primary_instance.psc_instance_config[0].service_attachment_link
load_balancing_scheme = ""
network = google_compute_network.psc_vpc.name
ip_address = google_compute_address.psc_consumer_address.id
allow_psc_global_access = true
}