Skip to content

Commit 861e0c5

Browse files
committed
2 parents fccedba + 3d2c5f6 commit 861e0c5

2 files changed

Lines changed: 145 additions & 0 deletions

File tree

mmv1/products/datastream/ConnectionProfile.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@ examples:
102102
test_vars_overrides:
103103
'deletion_protection': 'false'
104104
exclude_test: true
105+
- name: 'datastream_stream_postgresql_sslconfig_server_and_client_verification'
106+
primary_resource_id: 'default'
107+
vars:
108+
connection_profile_id: 'profile-id'
109+
deletion_protection: 'true'
110+
database_instance_name: 'my-instance'
111+
test_vars_overrides:
112+
'deletion_protection': 'false'
113+
oics_vars_overrides:
114+
'deletion_protection': 'false'
115+
external_providers: ["random"]
116+
skip_vcr: true
117+
ignore_read_extra:
118+
- 'postgresql_profile.0.password'
105119
- name: 'datastream_connection_profile_salesforce'
106120
primary_resource_id: 'default'
107121
vars:
@@ -371,6 +385,68 @@ properties:
371385
description: |
372386
Database for the PostgreSQL connection.
373387
required: true
388+
- name: 'sslConfig'
389+
type: NestedObject
390+
description: |
391+
SSL configuration for the PostgreSQL connection.
392+
properties:
393+
- name: 'serverVerification'
394+
type: NestedObject
395+
description: |
396+
If this field is set, the communication will be encrypted with TLS encryption
397+
and the server identity will be authenticated.
398+
exactly_one_of:
399+
- 'ssl_config.0.server_verification'
400+
- 'ssl_config.0.server_and_client_verification'
401+
properties:
402+
- name: 'caCertificate'
403+
type: String
404+
description: PEM-encoded server root CA certificate.
405+
required: true
406+
immutable: true
407+
sensitive: true
408+
ignore_read: true
409+
- name: 'serverAndClientVerification'
410+
type: NestedObject
411+
description: |
412+
If this field is set, the communication will be encrypted with TLS encryption
413+
and both the server identity and the client identity will be authenticated.
414+
exactly_one_of:
415+
- 'ssl_config.0.server_verification'
416+
- 'ssl_config.0.server_and_client_verification'
417+
ignore_read: true
418+
properties:
419+
- name: 'clientCertificate'
420+
type: String
421+
description: |
422+
PEM-encoded certificate used by the source database to authenticate the
423+
client identity (i.e., the Datastream's identity). This certificate is
424+
signed by either a root certificate trusted by the server or one or more
425+
intermediate certificates (which is stored with the leaf certificate) to
426+
link to this certificate to the trusted root certificate.
427+
immutable: true
428+
required: true
429+
sensitive: true
430+
ignore_read: true
431+
- name: 'clientKey'
432+
type: String
433+
description: |
434+
PEM-encoded private key associated with the client certificate.
435+
This value will be used during the SSL/TLS handshake, allowing
436+
the PostgreSQL server to authenticate the client's identity,
437+
i.e. identity of the stream.
438+
immutable: true
439+
required: true
440+
sensitive: true
441+
ignore_read: true
442+
- name: 'caCertificate'
443+
type: String
444+
description: |
445+
PEM-encoded server root CA certificate.
446+
immutable: true
447+
required: true
448+
sensitive: true
449+
ignore_read: true
374450
- name: 'salesforceProfile'
375451
min_version: beta
376452
type: NestedObject
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
data "google_datastream_static_ips" "datastream_ips" {
2+
location = "us-central1"
3+
}
4+
5+
resource "google_sql_database_instance" "instance" {
6+
name = "{{index $.Vars "database_instance_name"}}"
7+
database_version = "POSTGRES_15"
8+
region = "us-central1"
9+
settings {
10+
tier = "db-f1-micro"
11+
ip_configuration {
12+
ipv4_enabled = true
13+
ssl_mode = "TRUSTED_CLIENT_CERTIFICATE_REQUIRED"
14+
dynamic "authorized_networks" {
15+
for_each = data.google_datastream_static_ips.datastream_ips.static_ips
16+
iterator = ip
17+
18+
content {
19+
name = format("datastream-%d", ip.key)
20+
value = ip.value
21+
}
22+
}
23+
}
24+
}
25+
26+
deletion_protection = {{index $.Vars "deletion_protection"}}
27+
}
28+
29+
resource "google_sql_database" "db" {
30+
instance = google_sql_database_instance.instance.name
31+
name = "db"
32+
}
33+
34+
resource "random_password" "pwd" {
35+
length = 16
36+
special = false
37+
}
38+
39+
resource "google_sql_user" "user" {
40+
name = "user"
41+
instance = google_sql_database_instance.instance.name
42+
password = random_password.pwd.result
43+
}
44+
45+
resource "google_sql_ssl_cert" "client_cert" {
46+
common_name = "client-name"
47+
instance = google_sql_database_instance.instance.name
48+
}
49+
50+
resource "google_datastream_connection_profile" "{{$.PrimaryResourceId}}" {
51+
display_name = "Connection Profile"
52+
location = "us-central1"
53+
connection_profile_id = "{{index $.Vars "connection_profile_id"}}"
54+
55+
postgresql_profile {
56+
hostname = google_sql_database_instance.instance.public_ip_address
57+
port = 5432
58+
username = "user"
59+
password = random_password.pwd.result
60+
database = google_sql_database.db.name
61+
ssl_config {
62+
server_and_client_verification {
63+
client_certificate = google_sql_ssl_cert.client_cert.cert
64+
client_key = google_sql_ssl_cert.client_cert.private_key
65+
ca_certificate = google_sql_ssl_cert.client_cert.server_ca_cert
66+
}
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)