|
| 1 | +/** |
| 2 | + * Copyright 2024 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 | +# This is the target project where you host the cloud DNS mapping, this can also be the current project |
| 18 | +data "google_project" "target_project" { |
| 19 | +} |
| 20 | + |
| 21 | +resource "google_project_iam_member" "default" { |
| 22 | + project = data.google_project.target_project.project_id |
| 23 | + role = "roles/dns.peer" |
| 24 | + member = "serviceAccount:service-${data.google_project.test_project.number}@gcp-sa-connectors.iam.gserviceaccount.com" |
| 25 | +} |
| 26 | + |
| 27 | +resource "google_compute_network" "default" { |
| 28 | + project = data.google_project.target_project.project_id |
| 29 | + name = "test" |
| 30 | + auto_create_subnetworks = false |
| 31 | +} |
| 32 | + |
| 33 | +resource "google_dns_managed_zone" "default" { |
| 34 | + name = "test-dns" |
| 35 | + dns_name = "private.example.com." |
| 36 | + visibility = "private" |
| 37 | + |
| 38 | + private_visibility_config { |
| 39 | + networks { |
| 40 | + network_url = google_compute_network.default.id |
| 41 | + } |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +# This is the current project. |
| 46 | +data "google_project" "test_project" { |
| 47 | +} |
| 48 | + |
| 49 | +# [START integrationconnectors_managed_zone_example] |
| 50 | +resource "google_integration_connectors_managed_zone" "test_managed_zone" { |
| 51 | + name = "test-managed-zone" |
| 52 | + description = "tf created resource" |
| 53 | + labels = { |
| 54 | + intent = "example" |
| 55 | + } |
| 56 | + target_project = data.google_project.target_project.project_id |
| 57 | + target_vpc = "test" |
| 58 | + dns = google_dns_managed_zone.default.dns_name |
| 59 | + depends_on = [google_project_iam_member.default] |
| 60 | +} |
| 61 | +# [END integrationconnectors_managed_zone_example] |
0 commit comments