Skip to content

Commit b7e1274

Browse files
committed
feat(cloud_sql): Add samples for Google/Customer-managed CAS instances.
1 parent ed73a79 commit b7e1274

File tree

6 files changed

+212
-0
lines changed
  • cloud_sql
    • mysql_instance_customer_managed_cas_ca
    • mysql_instance_google_managed_cas_ca
    • postgres_instance_customer_managed_cas_ca
    • postgres_instance_google_managed_cas_ca
    • sqlserver_instance_customer_managed_cas_ca
    • sqlserver_instance_google_managed_cas_ca

6 files changed

+212
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
# [START cloud_sql_mysql_instance_customer_managed_cas_ca]
18+
resource "google_sql_database_instance" "mysql_instance" {
19+
name = "mysql-instance"
20+
region = "asia-northeast1"
21+
database_version = "MYSQL_8_0"
22+
settings {
23+
tier = "db-f1-micro"
24+
ip_configuration {
25+
# The following server CA mode lets the instance use customer-managed CAS CA to issue server certificates.
26+
# https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1beta4/instances#ipconfiguration
27+
server_ca_mode = "CUSTOMER_MANAGED_CAS_CA"
28+
# This is the name of the customer-owned CAS CA pool.
29+
server_ca_pool = "projects/my-project/locations/asia-northeast1/caPools/my-pool"
30+
}
31+
}
32+
# set `deletion_protection` to true, will ensure that one cannot accidentally delete this instance by
33+
# use of Terraform whereas `deletion_protection_enabled` flag protects this instance at the GCP level.
34+
deletion_protection = false
35+
}
36+
# [END cloud_sql_mysql_instance_customer_managed_cas_ca]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
# [START cloud_sql_mysql_instance_google_managed_cas_ca]
18+
resource "google_sql_database_instance" "mysql_instance" {
19+
name = "mysql-instance"
20+
region = "asia-northeast1"
21+
database_version = "MYSQL_8_0"
22+
settings {
23+
tier = "db-f1-micro"
24+
ip_configuration {
25+
# The following server CA mode lets the instance use Google-managed CAS CA to issue server certificates.
26+
# https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1beta4/instances#ipconfiguration
27+
server_ca_mode = "GOOGLE_MANAGED_CAS_CA"
28+
}
29+
}
30+
# set `deletion_protection` to true, will ensure that one cannot accidentally delete this instance by
31+
# use of Terraform whereas `deletion_protection_enabled` flag protects this instance at the GCP level.
32+
deletion_protection = false
33+
}
34+
# [END cloud_sql_mysql_instance_google_managed_cas_ca]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
# [START cloud_sql_postgres_instance_google_managed_cas_ca]
18+
resource "google_sql_database_instance" "postgres_instance" {
19+
name = "postgres-instance"
20+
region = "asia-northeast1"
21+
database_version = "POSTGRES_14"
22+
settings {
23+
tier = "db-custom-2-7680"
24+
ip_configuration {
25+
# The following server CA mode lets the instance use customer-managed CAS CA to issue server certificates.
26+
# https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances#ipconfiguration
27+
server_ca_mode = "CUSTOMER_MANAGED_CAS_CA"
28+
# This is the name of the customer-owned CAS CA pool.
29+
server_ca_pool = "projects/my-project/locations/asia-northeast1/caPools/my-pool"
30+
}
31+
}
32+
# set `deletion_protection` to true, will ensure that one cannot accidentally delete this instance by
33+
# use of Terraform whereas `deletion_protection_enabled` flag protects this instance at the GCP level.
34+
deletion_protection = false
35+
}
36+
# [END cloud_sql_postgres_instance_google_managed_cas_ca]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
# [START cloud_sql_postgres_instance_google_managed_cas_ca]
18+
resource "google_sql_database_instance" "postgres_instance" {
19+
name = "postgres-instance"
20+
region = "asia-northeast1"
21+
database_version = "POSTGRES_14"
22+
settings {
23+
tier = "db-custom-2-7680"
24+
ip_configuration {
25+
# The following server CA mode lets the instance use Google-managed CAS CA to issue server certificates.
26+
# https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1beta4/instances#ipconfiguration
27+
server_ca_mode = "GOOGLE_MANAGED_CAS_CA"
28+
}
29+
}
30+
# set `deletion_protection` to true, will ensure that one cannot accidentally delete this instance by
31+
# use of Terraform whereas `deletion_protection_enabled` flag protects this instance at the GCP level.
32+
deletion_protection = false
33+
}
34+
# [END cloud_sql_postgres_instance_google_managed_cas_ca]
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
# [START cloud_sql_sqlserver_instance_require_ssl]
18+
resource "google_sql_database_instance" "sqlserver_instance" {
19+
name = "sqlserver-instance"
20+
region = "asia-northeast1"
21+
database_version = "SQLSERVER_2019_STANDARD"
22+
root_password = "INSERT-PASSWORD-HERE"
23+
settings {
24+
tier = "db-custom-2-7680"
25+
ip_configuration {
26+
# The following server CA mode lets the instance use customer-managed CAS CA to issue server certificates.
27+
# https://cloud.google.com/sql/docs/sqlserver/admin-api/rest/v1beta4/instances#ipconfiguration
28+
server_ca_mode = "CUSTOMER_MANAGED_CAS_CA"
29+
# This is the name of the customer-owned CAS CA pool.
30+
server_ca_pool = "projects/my-project/locations/asia-northeast1/caPools/my-pool"
31+
}
32+
}
33+
# set `deletion_protection` to true, will ensure that one cannot accidentally delete this instance by
34+
# use of Terraform whereas `deletion_protection_enabled` flag protects this instance at the GCP level.
35+
deletion_protection = false
36+
}
37+
# [END cloud_sql_sqlserver_instance_require_ssl]
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
# [START cloud_sql_sqlserver_instance_require_ssl]
18+
resource "google_sql_database_instance" "sqlserver_instance" {
19+
name = "sqlserver-instance"
20+
region = "asia-northeast1"
21+
database_version = "SQLSERVER_2019_STANDARD"
22+
root_password = "INSERT-PASSWORD-HERE"
23+
settings {
24+
tier = "db-custom-2-7680"
25+
ip_configuration {
26+
# The following server CA mode lets the instance use Google-managed CAS CA to issue server certificates.
27+
# https://cloud.google.com/sql/docs/sqlserver/admin-api/rest/v1beta4/instances#ipconfiguration
28+
server_ca_mode = "GOOGLE_MANAGED_CAS_CA"
29+
}
30+
}
31+
# set `deletion_protection` to true, will ensure that one cannot accidentally delete this instance by
32+
# use of Terraform whereas `deletion_protection_enabled` flag protects this instance at the GCP level.
33+
deletion_protection = false
34+
}
35+
# [END cloud_sql_sqlserver_instance_require_ssl]

0 commit comments

Comments
 (0)