diff --git a/.gitignore b/.gitignore index d9c0bc0298..bd22a61595 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ website/node_modules *.test *.iml *.tfvars +service-account.json log.* website/vendor diff --git a/examples/gcp-atlas-privatelink/main.tf b/examples/gcp-atlas-privatelink/main.tf index ef39699378..6c3d847b5f 100644 --- a/examples/gcp-atlas-privatelink/main.tf +++ b/examples/gcp-atlas-privatelink/main.tf @@ -6,7 +6,7 @@ resource "mongodbatlas_privatelink_endpoint" "test" { # Create a Google Network resource "google_compute_network" "default" { - project = var.gcp_project + project = var.gcp_project_id name = "my-network" } @@ -27,7 +27,7 @@ resource "google_compute_address" "default" { subnetwork = google_compute_subnetwork.default.id address_type = "INTERNAL" address = "10.0.42.${count.index}" - region = var.gcp_region + region = google_compute_subnetwork.default.region depends_on = [mongodbatlas_privatelink_endpoint.test] } @@ -35,29 +35,28 @@ resource "google_compute_address" "default" { # Create 50 Forwarding rules resource "google_compute_forwarding_rule" "default" { count = 50 - project = var.gcp_project - region = var.gcp_region - name = "tf-test${count.index}" target = mongodbatlas_privatelink_endpoint.test.service_attachment_names[count.index] + project = google_compute_address.default[count.index].project + region = google_compute_address.default[count.index].region + name = google_compute_address.default[count.index].name ip_address = google_compute_address.default[count.index].id network = google_compute_network.default.id load_balancing_scheme = "" } - resource "mongodbatlas_privatelink_endpoint_service" "test" { project_id = mongodbatlas_privatelink_endpoint.test.project_id private_link_id = mongodbatlas_privatelink_endpoint.test.private_link_id provider_name = "GCP" endpoint_service_id = google_compute_network.default.name - gcp_project_id = var.gcp_project + gcp_project_id = var.gcp_project_id dynamic "endpoints" { for_each = mongodbatlas_privatelink_endpoint.test.service_attachment_names content { ip_address = google_compute_address.default[endpoints.key].address - endpoint_name = google_compute_address.default[endpoints.key].name + endpoint_name = google_compute_forwarding_rule.default[endpoints.key].name } } diff --git a/examples/gcp-atlas-privatelink/provider.tf b/examples/gcp-atlas-privatelink/provider.tf new file mode 100644 index 0000000000..a8a7273d9d --- /dev/null +++ b/examples/gcp-atlas-privatelink/provider.tf @@ -0,0 +1,11 @@ +provider "mongodbatlas" { + public_key = var.public_key + private_key = var.private_key +} +provider "google" { + # Credentials commented out to pass lint + # Add your own service-account & path to run example + # credentials = file("service-account.json") + project = var.gcp_project_id + region = var.gcp_region # us-central1 +} diff --git a/examples/gcp-atlas-privatelink/variables.tf b/examples/gcp-atlas-privatelink/variables.tf index 7fd204071e..2bbcdf1677 100644 --- a/examples/gcp-atlas-privatelink/variables.tf +++ b/examples/gcp-atlas-privatelink/variables.tf @@ -1,10 +1,15 @@ - -variable "project_id" { - default = "PROJECT-ID" -} -variable "gcp_project" { +variable "gcp_project_id" { default = "GCP-PROJECT" } variable "gcp_region" { default = "us-central1" } +variable "project_id" { + default = "PROJECT-ID" +} +variable "public_key" { + description = "Public API key to authenticate to Atlas" +} +variable "private_key" { + description = "Private API key to authenticate to Atlas" +} diff --git a/website/docs/r/privatelink_endpoint_service.html.markdown b/website/docs/r/privatelink_endpoint_service.html.markdown index 766c419aa2..0abfcf47e6 100644 --- a/website/docs/r/privatelink_endpoint_service.html.markdown +++ b/website/docs/r/privatelink_endpoint_service.html.markdown @@ -114,10 +114,10 @@ resource "google_compute_address" "default" { # Create 50 Forwarding rules resource "google_compute_forwarding_rule" "default" { count = 50 - project = var.gcp_project - region = var.gcp_region - name = "tf-test${count.index}" target = mongodbatlas_privatelink_endpoint.test.service_attachment_names[count.index] + project = google_compute_address.default[count.index].project + region = google_compute_address.default[count.index].region + name = google_compute_address.default[count.index].name ip_address = google_compute_address.default[count.index].id network = google_compute_network.default.id load_balancing_scheme = "" @@ -136,7 +136,7 @@ resource "mongodbatlas_privatelink_endpoint_service" "test" { content { ip_address = google_compute_address.default[endpoints.key].address - endpoint_name = google_compute_address.default[endpoints.key].name + endpoint_name = google_compute_forwarding_rule.default[endpoints.key].name } }