Skip to content

Commit 971c6b1

Browse files
GauravJain21zli82016
authored andcommitted
Add examples for AlloyDB Major Version Upgrade (GoogleCloudPlatform#13177)
Co-authored-by: Zhenhua Li <[email protected]>
1 parent ecbda76 commit 971c6b1

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed

mmv1/products/alloydb/Cluster.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ examples:
6565
primary_resource_id: 'default'
6666
vars:
6767
alloydb_cluster_name: 'alloydb-cluster'
68+
- name: 'alloydb_cluster_before_upgrade'
69+
primary_resource_id: 'default'
70+
vars:
71+
alloydb_cluster_name: 'alloydb-cluster'
72+
alloydb_instance_name: 'alloydb-instance'
73+
network_name: 'alloydb-network'
74+
- name: 'alloydb_cluster_after_upgrade'
75+
primary_resource_id: 'default'
76+
vars:
77+
alloydb_cluster_name: 'alloydb-cluster'
78+
alloydb_instance_name: 'alloydb-instance'
79+
network_name: 'alloydb-network'
6880
- name: 'alloydb_cluster_full'
6981
primary_resource_id: 'full'
7082
vars:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
resource "google_alloydb_instance" "{{$.PrimaryResourceId}}" {
2+
cluster = google_alloydb_cluster.{{$.PrimaryResourceId}}.name
3+
instance_id = "{{index $.Vars "alloydb_instance_name"}}"
4+
instance_type = "PRIMARY"
5+
6+
machine_config {
7+
cpu_count = 2
8+
}
9+
10+
depends_on = [google_service_networking_connection.vpc_connection]
11+
}
12+
13+
resource "google_alloydb_cluster" "{{$.PrimaryResourceId}}" {
14+
cluster_id = "{{index $.Vars "alloydb_cluster_name"}}"
15+
location = "us-central1"
16+
network_config {
17+
network = google_compute_network.default.id
18+
}
19+
database_version = "POSTGRES_15"
20+
21+
initial_user {
22+
password = "{{index $.Vars "alloydb_cluster_name"}}"
23+
}
24+
}
25+
26+
data "google_project" "project" {}
27+
28+
resource "google_compute_network" "default" {
29+
name = "{{index $.Vars "network_name"}}"
30+
}
31+
32+
resource "google_compute_global_address" "private_ip_alloc" {
33+
name = "{{index $.Vars "alloydb_cluster_name"}}"
34+
address_type = "INTERNAL"
35+
purpose = "VPC_PEERING"
36+
prefix_length = 16
37+
network = google_compute_network.default.id
38+
}
39+
40+
resource "google_service_networking_connection" "vpc_connection" {
41+
network = google_compute_network.default.id
42+
service = "servicenetworking.googleapis.com"
43+
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
resource "google_alloydb_instance" "{{$.PrimaryResourceId}}" {
2+
cluster = google_alloydb_cluster.{{$.PrimaryResourceId}}.name
3+
instance_id = "{{index $.Vars "alloydb_instance_name"}}"
4+
instance_type = "PRIMARY"
5+
6+
machine_config {
7+
cpu_count = 2
8+
}
9+
10+
depends_on = [google_service_networking_connection.vpc_connection]
11+
}
12+
13+
resource "google_alloydb_cluster" "{{$.PrimaryResourceId}}" {
14+
cluster_id = "{{index $.Vars "alloydb_cluster_name"}}"
15+
location = "us-central1"
16+
network_config {
17+
network = google_compute_network.default.id
18+
}
19+
database_version = "POSTGRES_14"
20+
21+
initial_user {
22+
password = "{{index $.Vars "alloydb_cluster_name"}}"
23+
}
24+
}
25+
26+
data "google_project" "project" {}
27+
28+
resource "google_compute_network" "default" {
29+
name = "{{index $.Vars "network_name"}}"
30+
}
31+
32+
resource "google_compute_global_address" "private_ip_alloc" {
33+
name = "{{index $.Vars "alloydb_cluster_name"}}"
34+
address_type = "INTERNAL"
35+
purpose = "VPC_PEERING"
36+
prefix_length = 16
37+
network = google_compute_network.default.id
38+
}
39+
40+
resource "google_service_networking_connection" "vpc_connection" {
41+
network = google_compute_network.default.id
42+
service = "servicenetworking.googleapis.com"
43+
reserved_peering_ranges = [google_compute_global_address.private_ip_alloc.name]
44+
}

0 commit comments

Comments
 (0)