Skip to content

Commit bfc365e

Browse files
authored
INTMDB-331 - Update GCP documentation (#793)
* Updated gcp compute address & forwarding rule examples * Fixed formatting * Commenting out credentials for fmting purposes
1 parent 11bd180 commit bfc365e

File tree

5 files changed

+33
-17
lines changed

5 files changed

+33
-17
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ website/node_modules
2727
*.test
2828
*.iml
2929
*.tfvars
30+
service-account.json
3031
log.*
3132

3233
website/vendor

examples/gcp-atlas-privatelink/main.tf

+7-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ resource "mongodbatlas_privatelink_endpoint" "test" {
66

77
# Create a Google Network
88
resource "google_compute_network" "default" {
9-
project = var.gcp_project
9+
project = var.gcp_project_id
1010
name = "my-network"
1111
}
1212

@@ -27,37 +27,36 @@ resource "google_compute_address" "default" {
2727
subnetwork = google_compute_subnetwork.default.id
2828
address_type = "INTERNAL"
2929
address = "10.0.42.${count.index}"
30-
region = var.gcp_region
30+
region = google_compute_subnetwork.default.region
3131

3232
depends_on = [mongodbatlas_privatelink_endpoint.test]
3333
}
3434

3535
# Create 50 Forwarding rules
3636
resource "google_compute_forwarding_rule" "default" {
3737
count = 50
38-
project = var.gcp_project
39-
region = var.gcp_region
40-
name = "tf-test${count.index}"
4138
target = mongodbatlas_privatelink_endpoint.test.service_attachment_names[count.index]
39+
project = google_compute_address.default[count.index].project
40+
region = google_compute_address.default[count.index].region
41+
name = google_compute_address.default[count.index].name
4242
ip_address = google_compute_address.default[count.index].id
4343
network = google_compute_network.default.id
4444
load_balancing_scheme = ""
4545
}
4646

47-
4847
resource "mongodbatlas_privatelink_endpoint_service" "test" {
4948
project_id = mongodbatlas_privatelink_endpoint.test.project_id
5049
private_link_id = mongodbatlas_privatelink_endpoint.test.private_link_id
5150
provider_name = "GCP"
5251
endpoint_service_id = google_compute_network.default.name
53-
gcp_project_id = var.gcp_project
52+
gcp_project_id = var.gcp_project_id
5453

5554
dynamic "endpoints" {
5655
for_each = mongodbatlas_privatelink_endpoint.test.service_attachment_names
5756

5857
content {
5958
ip_address = google_compute_address.default[endpoints.key].address
60-
endpoint_name = google_compute_address.default[endpoints.key].name
59+
endpoint_name = google_compute_forwarding_rule.default[endpoints.key].name
6160
}
6261
}
6362

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
provider "mongodbatlas" {
2+
public_key = var.public_key
3+
private_key = var.private_key
4+
}
5+
provider "google" {
6+
# Credentials commented out to pass lint
7+
# Add your own service-account & path to run example
8+
# credentials = file("service-account.json")
9+
project = var.gcp_project_id
10+
region = var.gcp_region # us-central1
11+
}
+10-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
2-
variable "project_id" {
3-
default = "PROJECT-ID"
4-
}
5-
variable "gcp_project" {
1+
variable "gcp_project_id" {
62
default = "GCP-PROJECT"
73
}
84
variable "gcp_region" {
95
default = "us-central1"
106
}
7+
variable "project_id" {
8+
default = "PROJECT-ID"
9+
}
10+
variable "public_key" {
11+
description = "Public API key to authenticate to Atlas"
12+
}
13+
variable "private_key" {
14+
description = "Private API key to authenticate to Atlas"
15+
}

website/docs/r/privatelink_endpoint_service.html.markdown

+4-4
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ resource "google_compute_address" "default" {
114114
# Create 50 Forwarding rules
115115
resource "google_compute_forwarding_rule" "default" {
116116
count = 50
117-
project = var.gcp_project
118-
region = var.gcp_region
119-
name = "tf-test${count.index}"
120117
target = mongodbatlas_privatelink_endpoint.test.service_attachment_names[count.index]
118+
project = google_compute_address.default[count.index].project
119+
region = google_compute_address.default[count.index].region
120+
name = google_compute_address.default[count.index].name
121121
ip_address = google_compute_address.default[count.index].id
122122
network = google_compute_network.default.id
123123
load_balancing_scheme = ""
@@ -136,7 +136,7 @@ resource "mongodbatlas_privatelink_endpoint_service" "test" {
136136
137137
content {
138138
ip_address = google_compute_address.default[endpoints.key].address
139-
endpoint_name = google_compute_address.default[endpoints.key].name
139+
endpoint_name = google_compute_forwarding_rule.default[endpoints.key].name
140140
}
141141
}
142142

0 commit comments

Comments
 (0)