|
| 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 | +data "google_project" "project" { |
| 18 | +} |
| 19 | + |
| 20 | +# [START vpc_sqlserver_instance_consumer_network] |
| 21 | +resource "google_compute_network" "consumer_network" { |
| 22 | + name = "consumer-network" |
| 23 | + auto_create_subnetworks = "true" |
| 24 | +} |
| 25 | +# [END vpc_sqlserver_instance_consumer_network] |
| 26 | + |
| 27 | +# [START cloud_sql_sqlserver_instance_psc_sa] |
| 28 | +resource "google_sql_database_instance" "default" { |
| 29 | + name = "sqlserver-instance" |
| 30 | + region = "us-central1" |
| 31 | + database_version = "SQLSERVER_2019_ENTERPRISE" |
| 32 | + root_password = "INSERT-PASSWORD-HERE" |
| 33 | + settings { |
| 34 | + tier = "db-custom-2-7680" |
| 35 | + availability_type = "REGIONAL" |
| 36 | + backup_configuration { |
| 37 | + enabled = true |
| 38 | + start_time = "20:55" |
| 39 | + } |
| 40 | + ip_configuration { |
| 41 | + psc_config { |
| 42 | + psc_enabled = true |
| 43 | + allowed_consumer_projects = [] # Add consumer project IDs here. |
| 44 | + psc_auto_connections { |
| 45 | + consumer_network = google_compute_network.consumer_network.id |
| 46 | + consumer_service_project_id = data.google_project.project.project_id |
| 47 | + } |
| 48 | + } |
| 49 | + ipv4_enabled = false |
| 50 | + } |
| 51 | + } |
| 52 | +} |
| 53 | +# [END cloud_sql_sqlserver_instance_psc_sa] |
0 commit comments