Skip to content

Commit 02eee4c

Browse files
add example and update docs
1 parent 9d0cdf1 commit 02eee4c

11 files changed

Lines changed: 206 additions & 54 deletions

File tree

docs/data-sources/stream_privatelink_endpoint.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -294,26 +294,20 @@ output "service_attachment_uris" {
294294

295295
### Azure Blob Storage Privatelink
296296
```terraform
297-
resource "mongodbatlas_stream_privatelink_endpoint" "azure_blob" {
298-
project_id = var.project_id
299-
provider_name = "AZURE"
300-
vendor = "AZURE_BLOB_STORAGE"
301-
region = var.azure_region
302-
service_endpoint_id = "/subscriptions/${var.azure_subscription_id}/resourceGroups/${var.azure_resource_group}/providers/Microsoft.Storage/storageAccounts/${var.azure_storage_account_name}"
303-
dns_domain = "${var.azure_storage_account_name}.blob.core.windows.net"
304-
}
305-
306-
data "mongodbatlas_stream_privatelink_endpoint" "azure_blob" {
307-
project_id = var.project_id
308-
id = mongodbatlas_stream_privatelink_endpoint.azure_blob.id
297+
resource "mongodbatlas_stream_privatelink_endpoint" "this" {
298+
project_id = var.project_id
299+
vendor = "AZURE_BLOB_STORAGE"
300+
provider_name = "AZURE"
301+
region = var.atlas_region
302+
# dns_domain follows the format '{storageAccount}.blob.core.windows.net'
303+
dns_domain = "${var.storage_account_name}.blob.core.windows.net"
304+
# service_endpoint_id follows the format '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Storage/storageAccounts/{storageAccount}'
305+
service_endpoint_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${var.azure_resource_group}/providers/Microsoft.Storage/storageAccounts/${var.storage_account_name}"
306+
depends_on = [azurerm_private_endpoint.blob_endpoint]
309307
}
310308
311309
output "privatelink_endpoint_id" {
312-
value = mongodbatlas_stream_privatelink_endpoint.azure_blob.id
313-
}
314-
315-
output "privatelink_endpoint_state" {
316-
value = data.mongodbatlas_stream_privatelink_endpoint.azure_blob.state
310+
value = mongodbatlas_stream_privatelink_endpoint.this.id
317311
}
318312
```
319313

@@ -329,7 +323,7 @@ output "privatelink_endpoint_state" {
329323

330324
- `arn` (String) Amazon Resource Name (ARN). Required for AWS Provider and MSK vendor.
331325
- `dns_domain` (String) The domain hostname. Required for the following provider and vendor combinations:
332-
326+
333327
* AWS provider with CONFLUENT vendor.
334328

335329
* AZURE provider with EVENTHUB, CONFLUENT, or AZURE_BLOB_STORAGE vendor. For AZURE_BLOB_STORAGE, this should follow the format '{storageAccount}.blob.core.windows.net'.

docs/data-sources/stream_privatelink_endpoints.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -294,21 +294,20 @@ output "service_attachment_uris" {
294294

295295
### Azure Blob Storage Privatelink
296296
```terraform
297-
resource "mongodbatlas_stream_privatelink_endpoint" "azure_blob" {
298-
project_id = var.project_id
299-
provider_name = "AZURE"
300-
vendor = "AZURE_BLOB_STORAGE"
301-
region = var.azure_region
302-
service_endpoint_id = "/subscriptions/${var.azure_subscription_id}/resourceGroups/${var.azure_resource_group}/providers/Microsoft.Storage/storageAccounts/${var.azure_storage_account_name}"
303-
dns_domain = "${var.azure_storage_account_name}.blob.core.windows.net"
304-
}
305-
306-
data "mongodbatlas_stream_privatelink_endpoints" "all" {
307-
project_id = var.project_id
297+
resource "mongodbatlas_stream_privatelink_endpoint" "this" {
298+
project_id = var.project_id
299+
vendor = "AZURE_BLOB_STORAGE"
300+
provider_name = "AZURE"
301+
region = var.atlas_region
302+
# dns_domain follows the format '{storageAccount}.blob.core.windows.net'
303+
dns_domain = "${var.storage_account_name}.blob.core.windows.net"
304+
# service_endpoint_id follows the format '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Storage/storageAccounts/{storageAccount}'
305+
service_endpoint_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${var.azure_resource_group}/providers/Microsoft.Storage/storageAccounts/${var.storage_account_name}"
306+
depends_on = [azurerm_private_endpoint.blob_endpoint]
308307
}
309308
310-
output "all_privatelink_endpoints" {
311-
value = data.mongodbatlas_stream_privatelink_endpoints.all.results[*].id
309+
output "privatelink_endpoint_id" {
310+
value = mongodbatlas_stream_privatelink_endpoint.this.id
312311
}
313312
```
314313

@@ -330,7 +329,7 @@ Read-Only:
330329

331330
- `arn` (String) Amazon Resource Name (ARN). Required for AWS Provider and MSK vendor.
332331
- `dns_domain` (String) The domain hostname. Required for the following provider and vendor combinations:
333-
332+
334333
* AWS provider with CONFLUENT vendor.
335334

336335
* AZURE provider with EVENTHUB, CONFLUENT, or AZURE_BLOB_STORAGE vendor. For AZURE_BLOB_STORAGE, this should follow the format '{storageAccount}.blob.core.windows.net'.

docs/resources/stream_privatelink_endpoint.md

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -294,30 +294,20 @@ output "service_attachment_uris" {
294294

295295
### Azure Blob Storage Privatelink
296296
```terraform
297-
resource "mongodbatlas_stream_privatelink_endpoint" "azure_blob" {
298-
project_id = var.project_id
299-
provider_name = "AZURE"
300-
vendor = "AZURE_BLOB_STORAGE"
301-
region = var.azure_region
302-
service_endpoint_id = "/subscriptions/${var.azure_subscription_id}/resourceGroups/${var.azure_resource_group}/providers/Microsoft.Storage/storageAccounts/${var.azure_storage_account_name}"
303-
dns_domain = "${var.azure_storage_account_name}.blob.core.windows.net"
304-
}
305-
306-
data "mongodbatlas_stream_privatelink_endpoint" "azure_blob" {
307-
project_id = var.project_id
308-
id = mongodbatlas_stream_privatelink_endpoint.azure_blob.id
309-
}
310-
311-
data "mongodbatlas_stream_privatelink_endpoints" "all" {
312-
project_id = var.project_id
297+
resource "mongodbatlas_stream_privatelink_endpoint" "this" {
298+
project_id = var.project_id
299+
vendor = "AZURE_BLOB_STORAGE"
300+
provider_name = "AZURE"
301+
region = var.atlas_region
302+
# dns_domain follows the format '{storageAccount}.blob.core.windows.net'
303+
dns_domain = "${var.storage_account_name}.blob.core.windows.net"
304+
# service_endpoint_id follows the format '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Storage/storageAccounts/{storageAccount}'
305+
service_endpoint_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${var.azure_resource_group}/providers/Microsoft.Storage/storageAccounts/${var.storage_account_name}"
306+
depends_on = [azurerm_private_endpoint.blob_endpoint]
313307
}
314308
315309
output "privatelink_endpoint_id" {
316-
value = mongodbatlas_stream_privatelink_endpoint.azure_blob.id
317-
}
318-
319-
output "privatelink_endpoint_state" {
320-
value = data.mongodbatlas_stream_privatelink_endpoint.azure_blob.state
310+
value = mongodbatlas_stream_privatelink_endpoint.this.id
321311
}
322312
```
323313

@@ -328,6 +318,7 @@ output "privatelink_endpoint_state" {
328318
- [AWS S3 PrivateLink](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v2.9.0/examples/mongodbatlas_stream_privatelink_endpoint/s3)
329319
- [GCP Confluent PrivateLink](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v2.9.0/examples/mongodbatlas_stream_privatelink_endpoint/gcp_confluent)
330320
- [Azure PrivateLink](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v2.9.0/examples/mongodbatlas_stream_privatelink_endpoint/azure)
321+
- [Azure Blob Storage PrivateLink](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v2.9.0/examples/mongodbatlas_stream_privatelink_endpoint/azure_blob_storage)
331322

332323
<!-- schema generated by tfplugindocs -->
333324
## Schema
@@ -348,7 +339,7 @@ output "privatelink_endpoint_state" {
348339

349340
- `arn` (String) Amazon Resource Name (ARN). Required for AWS Provider and MSK vendor.
350341
- `dns_domain` (String) The domain hostname. Required for the following provider and vendor combinations:
351-
342+
352343
* AWS provider with CONFLUENT vendor.
353344

354345
* AZURE provider with EVENTHUB, CONFLUENT, or AZURE_BLOB_STORAGE vendor. For AZURE_BLOB_STORAGE, this should follow the format '{storageAccount}.blob.core.windows.net'.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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_storage_account" "storage" {
21+
name = var.storage_account_name
22+
resource_group_name = azurerm_resource_group.rg.name
23+
location = azurerm_resource_group.rg.location
24+
account_tier = "Standard"
25+
account_replication_type = "LRS"
26+
# Disable public access so all traffic goes through the private endpoint
27+
public_network_access_enabled = false
28+
}
29+
30+
resource "azurerm_private_dns_zone" "dns_zone" {
31+
name = "privatelink.blob.core.windows.net"
32+
resource_group_name = azurerm_resource_group.rg.name
33+
}
34+
35+
resource "azurerm_private_dns_zone_virtual_network_link" "dns_zone_link" {
36+
name = "${var.vnet_name}-dns-link"
37+
resource_group_name = azurerm_resource_group.rg.name
38+
private_dns_zone_name = azurerm_private_dns_zone.dns_zone.name
39+
virtual_network_id = azurerm_virtual_network.vnet.id
40+
}
41+
42+
resource "azurerm_private_endpoint" "blob_endpoint" {
43+
name = "pe-${var.storage_account_name}"
44+
location = azurerm_resource_group.rg.location
45+
resource_group_name = azurerm_resource_group.rg.name
46+
subnet_id = azurerm_subnet.subnet.id
47+
48+
private_service_connection {
49+
name = "psc-${var.storage_account_name}"
50+
is_manual_connection = false
51+
private_connection_resource_id = azurerm_storage_account.storage.id
52+
subresource_names = ["blob"]
53+
}
54+
55+
private_dns_zone_group {
56+
name = "default-dns-group"
57+
private_dns_zone_ids = [azurerm_private_dns_zone.dns_zone.id]
58+
}
59+
60+
depends_on = [azurerm_private_dns_zone_virtual_network_link.dns_zone_link]
61+
}
62+
63+
data "azurerm_client_config" "current" {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
resource "mongodbatlas_stream_privatelink_endpoint" "this" {
2+
project_id = var.project_id
3+
vendor = "AZURE_BLOB_STORAGE"
4+
provider_name = "AZURE"
5+
region = var.atlas_region
6+
# dns_domain follows the format '{storageAccount}.blob.core.windows.net'
7+
dns_domain = "${var.storage_account_name}.blob.core.windows.net"
8+
# service_endpoint_id follows the format '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Storage/storageAccounts/{storageAccount}'
9+
service_endpoint_id = "/subscriptions/${data.azurerm_client_config.current.subscription_id}/resourceGroups/${var.azure_resource_group}/providers/Microsoft.Storage/storageAccounts/${var.storage_account_name}"
10+
depends_on = [azurerm_private_endpoint.blob_endpoint]
11+
}
12+
13+
output "privatelink_endpoint_id" {
14+
value = mongodbatlas_stream_privatelink_endpoint.this.id
15+
}
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+
client_id = var.atlas_client_id
8+
client_secret = var.atlas_client_secret
9+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Azure variables
2+
variable "azure_region" {
3+
description = "The Azure region where resources will be created."
4+
type = string
5+
}
6+
7+
variable "azure_resource_group" {
8+
description = "Name for the Azure resource group."
9+
type = string
10+
}
11+
12+
variable "storage_account_name" {
13+
description = "Globally unique name for the Azure Storage Account (3-24 lowercase alphanumeric characters)."
14+
type = string
15+
}
16+
17+
variable "vnet_name" {
18+
description = "Name for the Azure Virtual Network."
19+
type = string
20+
}
21+
22+
variable "subnet_name" {
23+
description = "Name for the Azure Subnet that will host the Private Endpoint."
24+
type = string
25+
}
26+
27+
variable "vnet_address_space" {
28+
description = "The address space for the Azure Virtual Network."
29+
type = list(string)
30+
}
31+
32+
variable "subnet_address_prefix" {
33+
description = "The address prefix for the Azure Subnet."
34+
type = list(string)
35+
}
36+
37+
# MongoDB Atlas variables
38+
variable "project_id" {
39+
description = "The ID of the MongoDB Atlas project."
40+
type = string
41+
}
42+
43+
variable "atlas_region" {
44+
description = "The Atlas region of the Provider's cluster. See [AZURE](https://www.mongodb.com/docs/atlas/reference/microsoft-azure/#stream-processing-instances)"
45+
type = string
46+
}
47+
48+
variable "atlas_client_id" {
49+
description = "MongoDB Atlas Service Account Client ID"
50+
type = string
51+
default = ""
52+
}
53+
54+
variable "atlas_client_secret" {
55+
description = "MongoDB Atlas Service Account Client Secret"
56+
type = string
57+
sensitive = true
58+
default = ""
59+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
terraform {
2+
required_providers {
3+
mongodbatlas = {
4+
source = "mongodb/mongodbatlas"
5+
}
6+
azurerm = {
7+
source = "hashicorp/azurerm"
8+
version = "~> 3.0"
9+
}
10+
}
11+
required_version = ">= 1.0"
12+
}

templates/data-sources/stream_privatelink_endpoint.md.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ subcategory: "Streams"
2020
### GCP Confluent Privatelink
2121
{{ tffile (printf "examples/%s/gcp_confluent/main.tf" .Name )}}
2222

23+
### Azure Blob Storage Privatelink
24+
{{ tffile (printf "examples/%s/azure_blob_storage/main.tf" .Name )}}
25+
2326
{{ .SchemaMarkdown | trimspace }}
2427

2528
For more information see: [MongoDB Atlas API - Streams Privatelink](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-createprivatelinkconnection) Documentation.

templates/data-sources/stream_privatelink_endpoints.md.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ subcategory: "Streams"
2020
### GCP Confluent Privatelink
2121
{{ tffile (printf "examples/mongodbatlas_stream_privatelink_endpoint/gcp_confluent/main.tf" )}}
2222

23+
### Azure Blob Storage Privatelink
24+
{{ tffile (printf "examples/mongodbatlas_stream_privatelink_endpoint/azure_blob_storage/main.tf" )}}
25+
2326
{{ .SchemaMarkdown | trimspace }}
2427

2528
For more information see: [MongoDB Atlas API - Streams Privatelink](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-createprivatelinkconnection) Documentation.

0 commit comments

Comments
 (0)