@@ -6,7 +6,7 @@ resource "mongodbatlas_privatelink_endpoint" "test" {
6
6
7
7
# Create a Google Network
8
8
resource "google_compute_network" "default" {
9
- project = var. gcp_project
9
+ project = var. gcp_project_id
10
10
name = " my-network"
11
11
}
12
12
@@ -27,37 +27,36 @@ resource "google_compute_address" "default" {
27
27
subnetwork = google_compute_subnetwork. default . id
28
28
address_type = " INTERNAL"
29
29
address = " 10.0.42.${ count . index } "
30
- region = var . gcp_region
30
+ region = google_compute_subnetwork . default . region
31
31
32
32
depends_on = [mongodbatlas_privatelink_endpoint . test ]
33
33
}
34
34
35
35
# Create 50 Forwarding rules
36
36
resource "google_compute_forwarding_rule" "default" {
37
37
count = 50
38
- project = var. gcp_project
39
- region = var. gcp_region
40
- name = " tf-test${ count . index } "
41
38
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
42
42
ip_address = google_compute_address. default [count . index ]. id
43
43
network = google_compute_network. default . id
44
44
load_balancing_scheme = " "
45
45
}
46
46
47
-
48
47
resource "mongodbatlas_privatelink_endpoint_service" "test" {
49
48
project_id = mongodbatlas_privatelink_endpoint. test . project_id
50
49
private_link_id = mongodbatlas_privatelink_endpoint. test . private_link_id
51
50
provider_name = " GCP"
52
51
endpoint_service_id = google_compute_network. default . name
53
- gcp_project_id = var. gcp_project
52
+ gcp_project_id = var. gcp_project_id
54
53
55
54
dynamic "endpoints" {
56
55
for_each = mongodbatlas_privatelink_endpoint. test . service_attachment_names
57
56
58
57
content {
59
58
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
61
60
}
62
61
}
63
62
0 commit comments