Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use self link in service networking connection #61

Merged
merged 1 commit into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ project adheres to [Semantic Versioning](http://semver.org/).

- the root module has been deprecated [#56]

### Fixed

- The network reference in the `private_service_access` module uses the self link. [#61]

## [1.2.0] - 2019-07-30

## [1.1.2] - 2019-06-14
Expand All @@ -36,5 +40,6 @@ project adheres to [Semantic Versioning](http://semver.org/).
[1.0.1]: https://github.com/terraform-google-modules/terraform-google-sql-db/compare/1.0.0...1.0.1
[1.0.0]: https://github.com/terraform-google-modules/terraform-google-sql-db/releases/tag/1.0.0

[#61]: https://github.com/terraform-google-modules/terraform-google-sql-db/pull/61
[#56]: https://github.com/terraform-google-modules/terraform-google-sql-db/pull/56
[#43]: https://github.com/terraform-google-modules/terraform-google-sql-db/pull/43
12 changes: 9 additions & 3 deletions modules/private_service_access/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,33 @@
* limitations under the License.
*/

data "google_compute_network" "main" {
name = "${var.vpc_network}"

project = "${var.project_id}"
}

// We define a VPC peering subnet that will be peered with the
// Cloud SQL instance network. The Cloud SQL instance will
// have a private IP within the provided range.
// https://cloud.google.com/vpc/docs/configure-private-services-access
resource "google_compute_global_address" "google-managed-services-range" {
provider = "google-beta"
project = "${var.project_id}"
name = "google-managed-services-${var.vpc_network}"
name = "google-managed-services-${data.google_compute_network.main.name}"
purpose = "VPC_PEERING"
address = "${var.address}"
prefix_length = "${var.prefix_length}"
ip_version = "${var.ip_version}"
labels = "${var.labels}"
address_type = "INTERNAL"
network = "${var.vpc_network}"
network = "${data.google_compute_network.main.self_link}"
}

# Creates the peering with the producer network.
resource "google_service_networking_connection" "private_service_access" {
provider = "google-beta"
network = "${google_compute_global_address.google-managed-services-range.network}"
network = "${data.google_compute_network.main.self_link}"
service = "servicenetworking.googleapis.com"
reserved_peering_ranges = ["${google_compute_global_address.google-managed-services-range.name}"]
}
Expand Down