-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathmain.tf
41 lines (33 loc) · 1.2 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
resource "google_alloydb_instance" "default" {
cluster = google_alloydb_cluster.default.name
instance_id = "alloydb-instance-${local.name_suffix}"
instance_type = "PRIMARY"
machine_config {
cpu_count = 2
}
depends_on = [google_service_networking_connection.vpc_connection]
}
resource "google_alloydb_cluster" "default" {
cluster_id = "alloydb-cluster-${local.name_suffix}"
location = "us-central1"
network = google_compute_network.default.id
initial_user {
password = "alloydb-cluster-${local.name_suffix}"
}
}
data "google_project" "project" {}
resource "google_compute_network" "default" {
name = "alloydb-network-${local.name_suffix}"
}
resource "google_compute_global_address" "private_ip_alloc" {
name = "alloydb-cluster-${local.name_suffix}"
address_type = "INTERNAL"
purpose = "VPC_PEERING"
prefix_length = 16
network = google_compute_network.default.id
}
resource "google_service_networking_connection" "vpc_connection" {
network = google_compute_network.default.id
service = "servicenetworking.googleapis.com"
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
}