forked from terraform-google-modules/docs-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
108 lines (97 loc) · 3.29 KB
/
main.tf
File metadata and controls
108 lines (97 loc) · 3.29 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
data "google_project" "project" {
}
resource "google_sql_database_instance" "source_csql" {
name = "source-csql-${local.name_suffix}"
database_version = "POSTGRES_15"
settings {
tier = "db-custom-2-13312"
deletion_protection_enabled = false
}
deletion_protection = false
}
resource "google_sql_ssl_cert" "source_sql_client_cert" {
common_name = "cert-${local.name_suffix}"
instance = google_sql_database_instance.source_csql.name
depends_on = [google_sql_database_instance.source_csql]
}
resource "google_sql_user" "source_sqldb_user" {
name = "username-${local.name_suffix}"
instance = google_sql_database_instance.source_csql.name
password = "password-${local.name_suffix}"
depends_on = [google_sql_ssl_cert.source_sql_client_cert]
}
resource "google_database_migration_service_connection_profile" "source_cp" {
location = "us-central1"
connection_profile_id = "source-cp-${local.name_suffix}"
display_name = "source-cp-${local.name_suffix}_display"
labels = {
foo = "bar"
}
postgresql {
host = google_sql_database_instance.source_csql.ip_address.0.ip_address
port = 3306
username = google_sql_user.source_sqldb_user.name
password = google_sql_user.source_sqldb_user.password
ssl {
client_key = google_sql_ssl_cert.source_sql_client_cert.private_key
client_certificate = google_sql_ssl_cert.source_sql_client_cert.cert
ca_certificate = google_sql_ssl_cert.source_sql_client_cert.server_ca_cert
type = "SERVER_CLIENT"
}
cloud_sql_id = "source-csql-${local.name_suffix}"
}
depends_on = [google_sql_user.source_sqldb_user]
}
resource "google_sql_database_instance" "destination_csql" {
name = "destination-csql-${local.name_suffix}"
database_version = "POSTGRES_15"
settings {
tier = "db-custom-2-13312"
deletion_protection_enabled = false
}
deletion_protection = false
}
resource "google_database_migration_service_connection_profile" "destination_cp" {
location = "us-central1"
connection_profile_id = "destination-cp-${local.name_suffix}"
display_name = "destination-cp-${local.name_suffix}_display"
labels = {
foo = "bar"
}
postgresql {
cloud_sql_id = "destination-csql-${local.name_suffix}"
}
depends_on = [google_sql_database_instance.destination_csql]
}
resource "google_database_migration_service_migration_job" "psqltopsqlobjects" {
location = "us-central1"
migration_job_id = "my-migrationid-${local.name_suffix}"
display_name = "my-migrationid-${local.name_suffix}_display"
labels = {
foo = "bar"
}
static_ip_connectivity {
}
source = google_database_migration_service_connection_profile.source_cp.name
destination = google_database_migration_service_connection_profile.destination_cp.name
type = "CONTINUOUS"
objects_config {
source_objects_config {
objects_selection_type = "SPECIFIED_OBJECTS"
object_configs {
object_identifier {
type = "DATABASE"
database = "my_database"
}
}
object_configs {
object_identifier {
type = "TABLE"
database = "my_other_database"
schema = "public"
table = "users"
}
}
}
}
}