-
Notifications
You must be signed in to change notification settings - Fork 210
feat: Adds port_mapping_enabled attribute to privatelink_endpoint and privatelink_endpoint_service
#4017
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
base: CLOUDP-346617-dev-gcp-port-based
Are you sure you want to change the base?
feat: Adds port_mapping_enabled attribute to privatelink_endpoint and privatelink_endpoint_service
#4017
Changes from 20 commits
332be39
9175dce
8a9562f
ca4cacf
ed3e818
d6725b9
7545b99
3752b5a
cfb1e0f
3a32c9f
df750a7
be386c1
0c9b674
6d555dc
a719ede
07cfdb7
6484466
f06647e
5e36067
0397c6b
80e3fcb
5f5ef57
3ab8f39
48449c5
4c79e7a
e12b299
993a4bb
0d3dca5
4857fe5
7b2d7a7
652d1d4
75313b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| ```release-note:enhancement | ||
| resource/mongodbatlas_privatelink_endpoint_service: Adds `port_mapping_enabled` attribute | ||
| ``` | ||
|
|
||
| ```release-note:enhancement | ||
| resource/mongodbatlas_privatelink_endpoint: Adds `port_mapping_enabled` attribute | ||
| ``` | ||
|
|
||
| ```release-note:enhancement | ||
| data-source/mongodbatlas_privatelink_endpoint_service: Adds `port_mapping_enabled` attribute | ||
| ``` | ||
|
|
||
| ```release-note:enhancement | ||
| data-source/mongodbatlas_privatelink_endpoint: Adds `port_mapping_enabled` attribute | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,9 +33,10 @@ resource "mongodbatlas_privatelink_endpoint_service" "test" { | |
| } | ||
|
|
||
| data "mongodbatlas_privatelink_endpoint_service" "test" { | ||
| project_id = mongodbatlas_privatelink_endpoint_service.test.project_id | ||
| private_link_id = mongodbatlas_privatelink_endpoint_service.test.private_link_id | ||
| interface_endpoint_id = mongodbatlas_privatelink_endpoint_service.test.interface_endpoint_id | ||
| project_id = mongodbatlas_privatelink_endpoint_service.test.project_id | ||
| private_link_id = mongodbatlas_privatelink_endpoint_service.test.private_link_id | ||
| endpoint_service_id = mongodbatlas_privatelink_endpoint_service.test.endpoint_service_id | ||
| provider_name = "AWS" | ||
| } | ||
| ``` | ||
|
|
||
|
|
@@ -71,9 +72,36 @@ resource "mongodbatlas_privatelink_endpoint_service" "test" { | |
| } | ||
|
|
||
| data "mongodbatlas_privatelink_endpoint_service" "test" { | ||
| project_id = mongodbatlas_privatelink_endpoint_service.test.project_id | ||
| private_link_id = mongodbatlas_privatelink_endpoint_service.test.private_link_id | ||
| interface_endpoint_id = mongodbatlas_privatelink_endpoint_service.test.interface_endpoint_id | ||
| project_id = mongodbatlas_privatelink_endpoint_service.test.project_id | ||
| private_link_id = mongodbatlas_privatelink_endpoint_service.test.private_link_id | ||
| endpoint_service_id = mongodbatlas_privatelink_endpoint_service.test.endpoint_service_id | ||
| provider_name = "AZURE" | ||
| } | ||
| ``` | ||
|
|
||
| ## Example with GCP (Legacy Architecture) | ||
|
|
||
| ```terraform | ||
| data "mongodbatlas_privatelink_endpoint_service" "test" { | ||
| project_id = mongodbatlas_privatelink_endpoint_service.test.project_id | ||
| private_link_id = mongodbatlas_privatelink_endpoint_service.test.private_link_id | ||
| endpoint_service_id = mongodbatlas_privatelink_endpoint_service.test.endpoint_service_id | ||
| provider_name = "GCP" | ||
| } | ||
| ``` | ||
|
|
||
| ## Example with GCP (Port-Based Architecture) | ||
|
|
||
| The new PSC port-based architecture simplifies setup by requiring only 1 endpoint instead of 50. Enable it by setting `port_mapping_enabled = true` on the endpoint resource. | ||
|
|
||
| **Important:** For the new port-based architecture, use `endpoint_service_id` (the forwarding rule name) and `private_endpoint_ip_address` (the IP address). The `endpoints` list is no longer used for the new architecture. | ||
|
|
||
| ```terraform | ||
| data "mongodbatlas_privatelink_endpoint_service" "test" { | ||
| project_id = mongodbatlas_privatelink_endpoint_service.test.project_id | ||
| private_link_id = mongodbatlas_privatelink_endpoint_service.test.private_link_id | ||
| endpoint_service_id = mongodbatlas_privatelink_endpoint_service.test.endpoint_service_id | ||
| provider_name = "GCP" | ||
| } | ||
| ``` | ||
|
|
||
|
|
@@ -84,8 +112,8 @@ data "mongodbatlas_privatelink_endpoint_service" "test" { | |
|
|
||
| * `project_id` - (Required) Unique identifier for the project. | ||
| * `private_link_id` - (Required) Unique identifier of the private endpoint service for which you want to retrieve a private endpoint. | ||
| * `endpoint_service_id` - (Required) Unique identifier of the `AWS` or `AZURE` or `GCP` resource. | ||
| * `provider_name` - (Required) Cloud provider for which you want to create a private endpoint. Atlas accepts `AWS` or `AZURE` or `GCP`. | ||
| * `endpoint_service_id` - (Required) Unique identifier of the interface endpoint you created in your VPC with the `AWS`, `AZURE`, or `GCP` resource. For GCP legacy architecture, this can be any identifier string. For GCP port-based architecture (when `port_mapping_enabled = true` on the endpoint resource), this should be the forwarding rule name. | ||
|
||
| * `provider_name` - (Required) Cloud provider for which you want to retrieve a private endpoint. Atlas accepts `AWS`, `AZURE` or `GCP`. | ||
|
|
||
| ## Attributes Reference | ||
|
|
||
|
|
@@ -118,9 +146,11 @@ In addition to all arguments above, the following attributes are exported: | |
| * `AVAILABLE` - Atlas approved the connection to your private endpoint. | ||
| * `FAILED` - Atlas failed to accept the connection your private endpoint. | ||
| * `DELETING` - Atlas is removing the connection to your private endpoint from the Private Link service. | ||
| * `endpoints` - Collection of individual private endpoints that comprise your network endpoint group. | ||
| * `gcp_endpoint_status` - Status of the individual GCP endpoint. Only populated for port-based architecture (when `port_mapping_enabled = true`on the endpoint resource). Returns one of the following values: `INITIATING`, `AVAILABLE`, `FAILED`, `DELETING`. | ||
| * `endpoints` - Collection of individual private endpoints that comprise your network endpoint group. Only populated for legacy GCP architecture. | ||
| * `endpoint_name` - Forwarding rule that corresponds to the endpoint you created in GCP. | ||
| * `ip_address` - Private IP address of the network endpoint group you created in GCP. | ||
| * `status` - Status of the endpoint. Atlas returns one of the [values shown above](https://docs.atlas.mongodb.com/reference/api/private-endpoints-endpoint-create-one/#std-label-ref-status-field). | ||
| * `port_mapping_enabled` - Flag that indicates whether this endpoint service uses PSC port-mapping. This is a read-only attribute that reflects the architecture type. When `true`, the endpoint service uses the new PSC port-based architecture (requires 1 endpoint). When `false`, it uses the legacy architecture. Only applicable for GCP provider. | ||
|
|
||
| See [MongoDB Atlas API](https://docs.atlas.mongodb.com/reference/api/private-endpoints-endpoint-get-one/) Documentation for more information. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,7 +73,7 @@ resource "mongodbatlas_privatelink_endpoint_service" "test" { | |
| } | ||
| ``` | ||
|
|
||
| ## Example with GCP | ||
| ## Example with GCP (Legacy Architecture) | ||
|
|
||
| ```terraform | ||
| resource "mongodbatlas_privatelink_endpoint" "test" { | ||
|
|
@@ -97,7 +97,7 @@ resource "google_compute_subnetwork" "default" { | |
| network = google_compute_network.default.id | ||
| } | ||
|
|
||
| # Create Google 50 Addresses | ||
| # Create Google 50 Addresses (required for legacy architecture) | ||
| resource "google_compute_address" "default" { | ||
| count = 50 | ||
| project = google_compute_subnetwork.default.project | ||
|
|
@@ -110,7 +110,7 @@ resource "google_compute_address" "default" { | |
| depends_on = [mongodbatlas_privatelink_endpoint.test] | ||
| } | ||
|
|
||
| # Create 50 Forwarding rules | ||
| # Create 50 Forwarding rules (required for legacy architecture) | ||
| resource "google_compute_forwarding_rule" "default" { | ||
| count = 50 | ||
| target = mongodbatlas_privatelink_endpoint.test.service_attachment_names[count.index] | ||
|
|
@@ -144,20 +144,86 @@ resource "mongodbatlas_privatelink_endpoint_service" "test" { | |
|
|
||
| ``` | ||
|
|
||
| ## Example with GCP (Port-Based Architecture) | ||
|
|
||
| The new PSC port-based architecture simplifies setup by requiring only 1 endpoint instead of 50. Enable it by setting `port_mapping_enabled = true` on the endpoint resource. | ||
|
|
||
| **Important:** For the new port-based architecture, use `endpoint_service_id` (the forwarding rule name) and `private_endpoint_ip_address` (the IP address). The `endpoints` list is no longer used for the new architecture. | ||
|
|
||
| ```terraform | ||
| resource "mongodbatlas_privatelink_endpoint" "test" { | ||
| project_id = var.project_id | ||
| provider_name = "GCP" | ||
| region = var.gcp_region | ||
| port_mapping_enabled = true # Enable new PSC port-based architecture | ||
| } | ||
|
|
||
| # Create a Google Network | ||
| resource "google_compute_network" "default" { | ||
| project = var.gcp_project | ||
| name = "my-network" | ||
| } | ||
|
|
||
| # Create a Google Sub Network | ||
| resource "google_compute_subnetwork" "default" { | ||
| project = google_compute_network.default.project | ||
| name = "my-subnet" | ||
| ip_cidr_range = "10.0.0.0/16" | ||
| region = var.gcp_region | ||
| network = google_compute_network.default.id | ||
| } | ||
|
|
||
| # Create Google Address (1 address for new PSC port-based architecture) | ||
| resource "google_compute_address" "default" { | ||
| project = google_compute_subnetwork.default.project | ||
| name = "tf-test-psc-endpoint" | ||
| subnetwork = google_compute_subnetwork.default.id | ||
| address_type = "INTERNAL" | ||
| address = "10.0.42.1" | ||
| region = google_compute_subnetwork.default.region | ||
|
|
||
| depends_on = [mongodbatlas_privatelink_endpoint.test] | ||
| } | ||
|
|
||
| # Create Forwarding Rule (1 rule for new PSC port-based architecture) | ||
| resource "google_compute_forwarding_rule" "default" { | ||
| target = mongodbatlas_privatelink_endpoint.test.service_attachment_names[0] | ||
| project = google_compute_address.default.project | ||
| region = google_compute_address.default.region | ||
| name = google_compute_address.default.name | ||
| ip_address = google_compute_address.default.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_forwarding_rule.default.name | ||
| private_endpoint_ip_address = google_compute_address.default.address | ||
| gcp_project_id = var.gcp_project_id | ||
|
|
||
| depends_on = [google_compute_forwarding_rule.default] | ||
| } | ||
|
|
||
| ``` | ||
|
|
||
| ### Further Examples | ||
| - [AWS PrivateLink Endpoint and Service](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v2.2.0/examples/mongodbatlas_privatelink_endpoint/aws/cluster) | ||
| - [Azure Private Link Endpoint and Service](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v2.2.0/examples/mongodbatlas_privatelink_endpoint/azure) | ||
| - [GCP Private Service Connect Endpoint and Service](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v2.2.0/examples/mongodbatlas_privatelink_endpoint/gcp) | ||
| - [GCP Private Service Connect Endpoint and Service (Legacy Architecture)](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v2.2.0/examples/mongodbatlas_privatelink_endpoint/gcp) | ||
| - [GCP Private Service Connect Endpoint and Service (Port-Based Architecture)](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v2.2.0/examples/mongodbatlas_privatelink_endpoint/gcp-port-based) | ||
|
|
||
| ## Argument Reference | ||
|
|
||
| * `project_id` - (Required) Unique identifier for the project. | ||
| * `private_link_id` - (Required) Unique identifier of the `AWS` or `AZURE` PrivateLink connection which is created by `mongodbatlas_privatelink_endpoint` resource. | ||
| * `endpoint_service_id` - (Required) Unique identifier of the interface endpoint you created in your VPC with the `AWS`, `AZURE` or `GCP` resource. | ||
| * `private_link_id` - (Required) Unique identifier of the `AWS`, `AZURE` or `GCP` PrivateLink connection which is created by `mongodbatlas_privatelink_endpoint` resource. | ||
| * `endpoint_service_id` - (Required) Unique identifier of the interface endpoint you created in your VPC with the `AWS`, `AZURE` or `GCP` resource. For GCP legacy architecture, this can be any identifier string. For GCP port-based architecture (when `port_mapping_enabled = true` on the endpoint resource), this should be the forwarding rule name. | ||
| * `provider_name` - (Required) Cloud provider for which you want to create a private endpoint. Atlas accepts `AWS`, `AZURE` or `GCP`. | ||
| * `private_endpoint_ip_address` - (Optional) Private IP address of the private endpoint network interface you created in your Azure VNet. Only for `AZURE`. | ||
| * `gcp_project_id` - (Optional) Unique identifier of the GCP project in which you created your endpoints. Only for `GCP`. | ||
| * `endpoints` - (Optional) Collection of individual private endpoints that comprise your endpoint group. Only for `GCP`. See below. | ||
| * `private_endpoint_ip_address` - (Optional) Private IP address of the private endpoint network interface. **Required for `AZURE`.** For GCP port-based architecture (when `port_mapping_enabled = true` on the endpoint resource), this is required and should be the IP address of the forwarding rule. For GCP legacy architecture, this is not used. | ||
|
||
| * `gcp_project_id` - (Optional) Unique identifier of the GCP project in which you created your endpoints. **Required for `GCP`** (both legacy and port-based architectures). Only for `GCP`. | ||
| * `endpoints` - (Optional) Collection of individual private endpoints that comprise your endpoint group. Only for `GCP` legacy architecture (when `port_mapping_enabled = false` on the endpoint resource). **Note:** For the new port-based architecture, this field is no longer used - use `endpoint_service_id` and `private_endpoint_ip_address` instead. | ||
| * `timeouts`- (Optional) The duration of time to wait for Private Endpoint Service to be created or deleted. The timeout value is defined by a signed sequence of decimal numbers with a time unit suffix such as: `1h45m`, `300s`, `10m`, etc. The valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. The default timeout for Private Endpoint create & delete is `2h`. Learn more about timeouts [here](https://www.terraform.io/plugin/sdkv2/resources/retries-and-customizable-timeouts). | ||
| * `delete_on_create_timeout`- (Optional) Indicates whether to delete the resource being created if a timeout is reached when waiting for completion. When set to `true` and timeout occurs, it triggers the deletion and returns immediately without waiting for deletion to complete. When set to `false`, the timeout will not trigger resource deletion. If you suspect a transient error when the value is `true`, wait before retrying to allow resource deletion to finish. Default is `true`. | ||
|
|
||
|
|
@@ -197,9 +263,10 @@ In addition to all arguments above, the following attributes are exported: | |
| * `AVAILABLE` - Atlas approved the connection to your private endpoint. | ||
| * `FAILED` - Atlas failed to accept the connection your private endpoint. | ||
| * `DELETING` - Atlas is removing the connection to your private endpoint from the Private Link service. | ||
| * `endpoint_group_name` - (Optional) Unique identifier of the endpoint group. The endpoint group encompasses all of the endpoints that you created in GCP. | ||
| * `endpoints` - Collection of individual private endpoints that comprise your network endpoint group. | ||
| * `gcp_endpoint_status` - Status of the individual GCP endpoint. Only populated for port-based architecture (when `port_mapping_enabled = true` on the endpoint resource). Returns one of the following values: `INITIATING`, `AVAILABLE`, `FAILED`, `DELETING`. | ||
| * `endpoints` - Collection of individual private endpoints that comprise your network endpoint group. Only populated for legacy GCP architecture. | ||
| * `status` - Status of the endpoint. Atlas returns one of the [values shown above](https://docs.atlas.mongodb.com/reference/api/private-endpoints-endpoint-create-one/#std-label-ref-status-field). | ||
| * `port_mapping_enabled` - Flag that indicates whether this endpoint service uses PSC port-mapping. This is a read-only attribute that reflects the architecture type. When `true`, the endpoint service uses the new PSC port-based architecture (requires 1 endpoint). When `false`, it uses the legacy architecture. Only applicable for GCP provider. | ||
|
|
||
| ## Import | ||
| Private Endpoint Link Connection can be imported using project ID and username, in the format `{project_id}--{private_link_id}--{endpoint_service_id}--{provider_name}`, e.g. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only other resource and ds in Private Endpoint Services group is https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/private_endpoint_regional_mode, can you confirm nothing changes there?