Skip to content

INTMDB-331 - Update GCP documentation #793

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

Merged
merged 3 commits into from
Aug 2, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ website/node_modules
*.test
*.iml
*.tfvars
service-account.json
log.*

website/vendor
Expand Down
15 changes: 7 additions & 8 deletions examples/gcp-atlas-privatelink/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand All @@ -27,37 +27,36 @@ 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]
}

# 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
}
}

Expand Down
11 changes: 11 additions & 0 deletions examples/gcp-atlas-privatelink/provider.tf
Original file line number Diff line number Diff line change
@@ -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
}
15 changes: 10 additions & 5 deletions examples/gcp-atlas-privatelink/variables.tf
Original file line number Diff line number Diff line change
@@ -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"
}
8 changes: 4 additions & 4 deletions website/docs/r/privatelink_endpoint_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand All @@ -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
}
}

Expand Down