Skip to content

Commit 35b8476

Browse files
authored
doc: The commit adds Azure Streams PrivateLink documentation and examples (#3299)
1 parent cd9d373 commit 35b8476

File tree

11 files changed

+269
-43
lines changed

11 files changed

+269
-43
lines changed

docs/data-sources/stream_privatelink_endpoint.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,23 +213,21 @@ output "privatelink_endpoint_id" {
213213
### Required
214214

215215
- `id` (String) The ID of the Private Link connection.
216-
- `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.
217-
218-
**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group or project id remains the same. The resource and corresponding endpoints use the term groups.
216+
- `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.<br>**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group or project id remains the same. The resource and corresponding endpoints use the term groups.
219217

220218
### Read-Only
221219

222-
- `arn` (String) Amazon Resource Name (ARN).
223-
- `dns_domain` (String) Domain name of Privatelink connected cluster.
224-
- `dns_sub_domain` (List of String) Sub-Domain name of Confluent cluster. These are typically your availability zones.
220+
- `arn` (String) Amazon Resource Name (ARN). Required for AWS Provider and MSK vendor.
221+
- `dns_domain` (String) The domain hostname. Required for the following provider and vendor combinations:<br>- AWS provider with CONFLUENT vendor.<br>- AZURE provider with EVENTHUB or CONFLUENT vendor.
222+
- `dns_sub_domain` (List of String) Sub-Domain name of Confluent cluster. These are typically your availability zones. Required for AWS Provider and CONFLUENT vendor. If your AWS CONFLUENT cluster doesn't use subdomains, you must set this to the empty array [].
225223
- `error_message` (String) Error message if the connection is in a failed state.
226224
- `interface_endpoint_id` (String) Interface endpoint ID that is created from the specified service endpoint ID.
227225
- `interface_endpoint_name` (String) Name of interface endpoint that is created from the specified service endpoint ID.
228226
- `provider_account_id` (String) Account ID from the cloud provider.
229-
- `provider_name` (String) Provider where the Kafka cluster is deployed.
230-
- `region` (String) When the vendor is `CONFLUENT`, this is the domain name of Confluent cluster. When the vendor is `MSK`, this is computed by the API from the provided `arn`.
231-
- `service_endpoint_id` (String) Service Endpoint ID.
227+
- `provider_name` (String) Provider where the Kafka cluster is deployed. Valid values are AWS and AZURE.
228+
- `region` (String) The region of the Provider’s cluster. See [AZURE](https://www.mongodb.com/docs/atlas/reference/microsoft-azure/#stream-processing-instances) and [AWS](https://www.mongodb.com/docs/atlas/reference/amazon-aws/#stream-processing-instances) supported regions. When the vendor is `CONFLUENT`, this is the domain name of Confluent cluster. When the vendor is `MSK`, this is computed by the API from the provided `arn`.
229+
- `service_endpoint_id` (String) For AZURE EVENTHUB, this is the [namespace endpoint ID](https://learn.microsoft.com/en-us/rest/api/eventhub/namespaces/get). For AWS CONFLUENT cluster, this is the [VPC Endpoint service name](https://docs.confluent.io/cloud/current/networking/private-links/aws-privatelink.html).
232230
- `state` (String) Status of the connection.
233-
- `vendor` (String) Vendor who manages the Kafka cluster.
231+
- `vendor` (String) Vendor that manages the Kafka cluster. The following are the vendor values per provider:<br>- MSK and CONFLUENT for the AWS provider.<br>- EVENTHUB and CONFLUENT for the AZURE provider.
234232

235233
For more information see: [MongoDB Atlas API - Streams Privatelink](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Streams/operation/createPrivateLinkConnection) Documentation.

docs/data-sources/stream_privatelink_endpoints.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,7 @@ output "privatelink_endpoint_id" {
212212

213213
### Required
214214

215-
- `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.
216-
217-
**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group or project id remains the same. The resource and corresponding endpoints use the term groups.
215+
- `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.<br>**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group or project id remains the same. The resource and corresponding endpoints use the term groups.
218216

219217
### Read-Only
220218

@@ -225,21 +223,19 @@ output "privatelink_endpoint_id" {
225223

226224
Read-Only:
227225

228-
- `arn` (String) Amazon Resource Name (ARN).
229-
- `dns_domain` (String) Domain name of Privatelink connected cluster.
230-
- `dns_sub_domain` (List of String) Sub-Domain name of Confluent cluster. These are typically your availability zones.
226+
- `arn` (String) Amazon Resource Name (ARN). Required for AWS Provider and MSK vendor.
227+
- `dns_domain` (String) The domain hostname. Required for the following provider and vendor combinations:<br>- AWS provider with CONFLUENT vendor.<br>- AZURE provider with EVENTHUB or CONFLUENT vendor.
228+
- `dns_sub_domain` (List of String) Sub-Domain name of Confluent cluster. These are typically your availability zones. Required for AWS Provider and CONFLUENT vendor. If your AWS CONFLUENT cluster doesn't use subdomains, you must set this to the empty array [].
231229
- `error_message` (String) Error message if the connection is in a failed state.
232230
- `id` (String) The ID of the Private Link connection.
233231
- `interface_endpoint_id` (String) Interface endpoint ID that is created from the specified service endpoint ID.
234232
- `interface_endpoint_name` (String) Name of interface endpoint that is created from the specified service endpoint ID.
235-
- `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.
236-
237-
**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group or project id remains the same. The resource and corresponding endpoints use the term groups.
233+
- `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.<br>**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group or project id remains the same. The resource and corresponding endpoints use the term groups.
238234
- `provider_account_id` (String) Account ID from the cloud provider.
239-
- `provider_name` (String) Provider where the Kafka cluster is deployed.
240-
- `region` (String) When the vendor is `CONFLUENT`, this is the domain name of Confluent cluster. When the vendor is `MSK`, this is computed by the API from the provided `arn`.
241-
- `service_endpoint_id` (String) Service Endpoint ID.
235+
- `provider_name` (String) Provider where the Kafka cluster is deployed. Valid values are AWS and AZURE.
236+
- `region` (String) The region of the Provider’s cluster. See [AZURE](https://www.mongodb.com/docs/atlas/reference/microsoft-azure/#stream-processing-instances) and [AWS](https://www.mongodb.com/docs/atlas/reference/amazon-aws/#stream-processing-instances) supported regions. When the vendor is `CONFLUENT`, this is the domain name of Confluent cluster. When the vendor is `MSK`, this is computed by the API from the provided `arn`.
237+
- `service_endpoint_id` (String) For AZURE EVENTHUB, this is the [namespace endpoint ID](https://learn.microsoft.com/en-us/rest/api/eventhub/namespaces/get). For AWS CONFLUENT cluster, this is the [VPC Endpoint service name](https://docs.confluent.io/cloud/current/networking/private-links/aws-privatelink.html).
242238
- `state` (String) Status of the connection.
243-
- `vendor` (String) Vendor who manages the Kafka cluster.
239+
- `vendor` (String) Vendor that manages the Kafka cluster. The following are the vendor values per provider:<br>- MSK and CONFLUENT for the AWS provider.<br>- EVENTHUB and CONFLUENT for the AZURE provider.
244240

245241
For more information see: [MongoDB Atlas API - Streams Privatelink](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Streams/operation/createPrivateLinkConnection) Documentation.

docs/resources/stream_privatelink_endpoint.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,17 @@ output "privatelink_endpoint_id" {
212212

213213
### Required
214214

215-
- `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.
216-
217-
**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group or project id remains the same. The resource and corresponding endpoints use the term groups.
218-
- `provider_name` (String) Provider where the Kafka cluster is deployed.
219-
- `vendor` (String) Vendor who manages the Kafka cluster.
215+
- `project_id` (String) Unique 24-hexadecimal digit string that identifies your project. Use the [/groups](#tag/Projects/operation/listProjects) endpoint to retrieve all projects to which the authenticated user has access.<br>**NOTE**: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group or project id remains the same. The resource and corresponding endpoints use the term groups.
216+
- `provider_name` (String) Provider where the Kafka cluster is deployed. Valid values are AWS and AZURE.
217+
- `vendor` (String) Vendor that manages the Kafka cluster. The following are the vendor values per provider:<br>- MSK and CONFLUENT for the AWS provider.<br>- EVENTHUB and CONFLUENT for the AZURE provider.
220218

221219
### Optional
222220

223-
- `arn` (String) Amazon Resource Name (ARN).
224-
- `dns_domain` (String) Domain name of Privatelink connected cluster.
225-
- `dns_sub_domain` (List of String) Sub-Domain name of Confluent cluster. These are typically your availability zones.
226-
- `region` (String) When the vendor is `CONFLUENT`, this is the domain name of Confluent cluster. When the vendor is `MSK`, this is computed by the API from the provided `arn`.
227-
- `service_endpoint_id` (String) Service Endpoint ID.
221+
- `arn` (String) Amazon Resource Name (ARN). Required for AWS Provider and MSK vendor.
222+
- `dns_domain` (String) The domain hostname. Required for the following provider and vendor combinations:<br>- AWS provider with CONFLUENT vendor.<br>- AZURE provider with EVENTHUB or CONFLUENT vendor.
223+
- `dns_sub_domain` (List of String) Sub-Domain name of Confluent cluster. These are typically your availability zones. Required for AWS Provider and CONFLUENT vendor. If your AWS CONFLUENT cluster doesn't use subdomains, you must set this to the empty array [].
224+
- `region` (String) The region of the Provider’s cluster. See [AZURE](https://www.mongodb.com/docs/atlas/reference/microsoft-azure/#stream-processing-instances) and [AWS](https://www.mongodb.com/docs/atlas/reference/amazon-aws/#stream-processing-instances) supported regions. When the vendor is `CONFLUENT`, this is the domain name of Confluent cluster. When the vendor is `MSK`, this is computed by the API from the provided `arn`.
225+
- `service_endpoint_id` (String) For AZURE EVENTHUB, this is the [namespace endpoint ID](https://learn.microsoft.com/en-us/rest/api/eventhub/namespaces/get). For AWS CONFLUENT cluster, this is the [VPC Endpoint service name](https://docs.confluent.io/cloud/current/networking/private-links/aws-privatelink.html).
228226

229227
### Read-Only
230228

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Example - Microsoft Azure and MongoDB Atlas Streams Private Endpoint
2+
3+
This example shows how to use Azure PrivateLink Endpoints with EventHub for Atlas Streams PrivateLink.
4+
5+
You must set the following variables for Atlas in main.tf:
6+
7+
- `public_key`: Public API key to authenticate to Atlas
8+
- `private_key`: Private API key to authenticate to Atlas
9+
- `project_id`: Unique 24-hexadecimal digit string that identifies your atlas project
10+
- `atlas_region`: Atlas region where you want to create the Streams PrivateLink resources. To learn more, see `Atlas Region` column in https://www.mongodb.com/docs/atlas/reference/microsoft-azure/#stream-processing-instances.
11+
12+
- Additional required fields in main.tf:
13+
- `dns_domain`: Hostname of the Event Hub Namespace in Azure, which is the dns_domain.
14+
- `service_endpoint_id`: Service Endpoint ID for the EventHub Namespace. You can find this in the Azure portal under the EventHub Namespace properties. It typically looks like `/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}`.
15+
16+
The following setup is for Azure PrivateLink with EventHub example in azure.tf. To learn more, see documentation https://learn.microsoft.com/en-us/azure/event-hubs/private-link-service#add-a-private-endpoint-using-azure-portal
17+
18+
- `azure_region`: The Azure region where you want to create the Azure PrivateLink resources. `Azure Region` column in https://www.mongodb.com/docs/atlas/reference/microsoft-azure/#stream-processing-instances.
19+
- `azure_resource_group`: The name of the Azure Resource Group where you want to create the PrivateLink resources.
20+
- `vnet_name`: The name of the Azure Virtual Network (VNet) where you want to create the PrivateLink resources.
21+
- `subnet_name`: The name of the subnet within the VNet where you want to create the PrivateLink resources.
22+
- `eventhub_namespace_name`: The name of the Azure EventHub Namespace that you want to use for the PrivateLink connection. Must be globally unique.
23+
- `eventhub_name`: The name of the Azure EventHub that you want to use for the PrivateLink connection.
24+
- `vnet_address_space`: The address space for the Azure Virtual Network.
25+
- `subnet_address_prefix`: The address prefix for the Azure Subnet.
26+
27+
## Usage
28+
29+
**1\. Ensure that your Azure credentials are set up.**
30+
31+
1. Install the Azure CLI by following the steps from the [official Azure documentation](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli).
32+
2. Run the command `az login` and authenticate using the default browser.
33+
3. Once authenticated, Azure returns the following user details:
34+
35+
**2\. Set up your MongoDB Atlas API keys.**
36+
1. Log in to your MongoDB Atlas account.
37+
2. Navigate to the "Project Access" section of your project.
38+
3. Create a new API key with the necessary permissions (Project Owner or similar).
39+
4. Copy the Public and Private keys to use with the Terraform configuration.
40+
41+
**3\. Create a terraform.tfvars file.**
42+
1. Create a file named `terraform.tfvars` in the same directory as your `main.tf`.
43+
2. Defining the required variables in the `terraform.tfvars` file.
44+
45+
**4\. Optional: Create the Azure resources with EventHub.**
46+
1. If you don't have an existing Azure EventHub Namespace and EventHub, you can create them using the provided `azure.tf` file.
47+
48+
**5\. Initialize Terraform.**
49+
1. Run the following command to initialize Terraform and download the required providers:
50+
```bash
51+
terraform init
52+
```
53+
**6\. Plan the Terraform deployment.**
54+
1. Run the following command to see the execution plan and verify the resources that will be created:
55+
```bash
56+
terraform plan
57+
```
58+
59+
**7\. Apply the Terraform configuration.**
60+
1. If the plan looks good, run the following command to create the resources:
61+
```bash
62+
terraform apply
63+
```
64+
65+
**8\. Destroy the Terraform resources.**
66+
1. When you no longer need the resources, you can destroy them by running the following command:
67+
```bash
68+
terraform destroy
69+
```
70+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
resource "azurerm_resource_group" "rg" {
2+
name = var.azure_resource_group
3+
location = var.azure_region
4+
}
5+
6+
resource "azurerm_virtual_network" "vnet" {
7+
name = var.vnet_name
8+
address_space = var.vnet_address_space
9+
location = azurerm_resource_group.rg.location
10+
resource_group_name = azurerm_resource_group.rg.name
11+
}
12+
13+
resource "azurerm_subnet" "subnet" {
14+
name = var.subnet_name
15+
resource_group_name = azurerm_resource_group.rg.name
16+
virtual_network_name = azurerm_virtual_network.vnet.name
17+
address_prefixes = var.subnet_address_prefix
18+
}
19+
20+
resource "azurerm_eventhub_namespace" "eventhub_ns" {
21+
name = var.eventhub_namespace_name
22+
location = azurerm_resource_group.rg.location
23+
resource_group_name = azurerm_resource_group.rg.name
24+
sku = "Standard" # Minimum SKU for Private Link
25+
capacity = 1
26+
}
27+
28+
resource "azurerm_eventhub" "eventhub" {
29+
name = var.eventhub_name
30+
namespace_name = azurerm_eventhub_namespace.eventhub_ns.name
31+
resource_group_name = azurerm_resource_group.rg.name
32+
partition_count = 1
33+
message_retention = 1
34+
}
35+
36+
resource "azurerm_private_dns_zone" "dns_zone" {
37+
name = "privatelink.servicebus.windows.net" # should always be "privatelink.servicebus.windows.net"
38+
resource_group_name = azurerm_resource_group.rg.name
39+
}
40+
41+
resource "azurerm_private_dns_zone_virtual_network_link" "dns_zone_link" {
42+
name = "${var.vnet_name}-dns-link"
43+
resource_group_name = azurerm_resource_group.rg.name
44+
private_dns_zone_name = azurerm_private_dns_zone.dns_zone.name
45+
virtual_network_id = azurerm_virtual_network.vnet.id
46+
}
47+
48+
resource "azurerm_private_endpoint" "eventhub_endpoint" {
49+
name = "pe-${var.eventhub_namespace_name}"
50+
location = azurerm_resource_group.rg.location
51+
resource_group_name = azurerm_resource_group.rg.name
52+
subnet_id = azurerm_subnet.subnet.id
53+
54+
private_service_connection {
55+
name = "psc-${var.eventhub_namespace_name}"
56+
is_manual_connection = false
57+
private_connection_resource_id = azurerm_eventhub_namespace.eventhub_ns.id
58+
subresource_names = ["namespace"]
59+
}
60+
61+
private_dns_zone_group {
62+
name = "default-dns-group"
63+
private_dns_zone_ids = [azurerm_private_dns_zone.dns_zone.id]
64+
}
65+
66+
depends_on = [azurerm_private_dns_zone_virtual_network_link.dns_zone_link]
67+
}
68+
69+
data "azurerm_client_config" "current" {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resource "mongodbatlas_stream_privatelink_endpoint" "test_stream_privatelink" {
2+
project_id = var.project_id
3+
# dns_domain comes from the hostname of the Event Hub Namespace in Azure.
4+
dns_domain = "${var.eventhub_namespace_name}.servicebus.windows.net"
5+
provider_name = "AZURE"
6+
region = var.atlas_region
7+
vendor = "EVENTHUB"
8+
# The service endpoint ID is generated as follows: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}
9+
service_endpoint_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${var.azure_resource_group}/providers/Microsoft.EventHub/namespaces/${var.eventhub_namespace_name}"
10+
depends_on = [azurerm_private_endpoint.eventhub_endpoint]
11+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
provider "azurerm" {
2+
features {}
3+
# assumes Azure CLI login ('az login') or other standard auth
4+
}
5+
6+
provider "mongodbatlas" {
7+
public_key = var.public_key
8+
private_key = var.private_key
9+
}

0 commit comments

Comments
 (0)