Skip to content

Commit c237b78

Browse files
feat: Adds support for AWS MSK clusters to mongodbatlas_stream_privatelink_endpoint (#3179)
* feat: Add support for AWS MSK clusters to `mongodbatlas_stream_privatelink_endpoint` * add docs * rename changelog file * reformat main.tf * update docs * Update .changelog/3179.txt Co-authored-by: Marco Suma <[email protected]> * update version to 1.30 * remove unnecessary CI skip * remove "failedUpdate" acceptance tests * update docs * fix test after merging --------- Co-authored-by: Marco Suma <[email protected]>
1 parent 5a3c0d3 commit c237b78

File tree

19 files changed

+829
-50
lines changed

19 files changed

+829
-50
lines changed

.changelog/3179.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/mongodbatlas_stream_privatelink_endpoint: Adds support for AWS MSK clusters
3+
```

docs/data-sources/stream_privatelink_endpoint.md

Lines changed: 130 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
`mongodbatlas_stream_privatelink_endpoint` describes a Privatelink Endpoint for Streams.
44

55
## Example Usages
6+
7+
### AWS Confluent Privatelink
68
```terraform
79
resource "confluent_environment" "staging" {
810
display_name = "Staging"
@@ -79,6 +81,132 @@ output "interface_endpoint_ids" {
7981
}
8082
```
8183

84+
### AWS MSK Privatelink
85+
```terraform
86+
resource "aws_vpc" "vpc" {
87+
cidr_block = "192.168.0.0/22"
88+
}
89+
90+
data "aws_availability_zones" "azs" {
91+
state = "available"
92+
}
93+
94+
resource "aws_subnet" "subnet_az1" {
95+
availability_zone = data.aws_availability_zones.azs.names[0]
96+
cidr_block = "192.168.0.0/24"
97+
vpc_id = aws_vpc.vpc.id
98+
}
99+
100+
resource "aws_subnet" "subnet_az2" {
101+
availability_zone = data.aws_availability_zones.azs.names[1]
102+
cidr_block = "192.168.1.0/24"
103+
vpc_id = aws_vpc.vpc.id
104+
}
105+
106+
resource "aws_security_group" "sg" {
107+
vpc_id = aws_vpc.vpc.id
108+
}
109+
110+
resource "aws_msk_cluster" "example" {
111+
cluster_name = var.msk_cluster_name
112+
kafka_version = "3.6.0"
113+
number_of_broker_nodes = 2
114+
115+
broker_node_group_info {
116+
instance_type = "kafka.m5.large"
117+
client_subnets = [
118+
aws_subnet.subnet_az1.id,
119+
aws_subnet.subnet_az2.id,
120+
]
121+
security_groups = [aws_security_group.sg.id]
122+
123+
connectivity_info {
124+
vpc_connectivity {
125+
client_authentication {
126+
sasl {
127+
scram = true
128+
}
129+
}
130+
}
131+
}
132+
}
133+
134+
client_authentication {
135+
sasl {
136+
scram = true
137+
}
138+
}
139+
140+
configuration_info {
141+
arn = aws_msk_configuration.example.arn
142+
revision = aws_msk_configuration.example.latest_revision
143+
}
144+
}
145+
146+
resource "aws_msk_cluster_policy" "example" {
147+
cluster_arn = aws_msk_cluster.example.arn
148+
149+
policy = jsonencode({
150+
Version = "2012-10-17",
151+
Statement = [{
152+
Effect = "Allow"
153+
Principal = {
154+
"AWS" = "arn:aws:iam::${var.aws_account_id}:root"
155+
}
156+
Action = [
157+
"kafka:CreateVpcConnection",
158+
"kafka:GetBootstrapBrokers",
159+
"kafka:DescribeCluster",
160+
"kafka:DescribeClusterV2"
161+
]
162+
Resource = aws_msk_cluster.example.arn
163+
}]
164+
})
165+
}
166+
167+
resource "aws_msk_single_scram_secret_association" "example" {
168+
cluster_arn = aws_msk_cluster.example.arn
169+
secret_arn = var.aws_secret_arn
170+
}
171+
172+
resource "aws_msk_configuration" "example" {
173+
name = "${var.msk_cluster_name}-msk-configuration"
174+
175+
# Default ASW MSK configuration with "allow.everyone.if.no.acl.found=false" added
176+
server_properties = <<PROPERTIES
177+
auto.create.topics.enable=false
178+
default.replication.factor=3
179+
min.insync.replicas=2
180+
num.io.threads=8
181+
num.network.threads=5
182+
num.partitions=1
183+
num.replica.fetchers=2
184+
replica.lag.time.max.ms=30000
185+
socket.receive.buffer.bytes=102400
186+
socket.request.max.bytes=104857600
187+
socket.send.buffer.bytes=102400
188+
unclean.leader.election.enable=true
189+
allow.everyone.if.no.acl.found=false
190+
PROPERTIES
191+
}
192+
193+
resource "mongodbatlas_stream_privatelink_endpoint" "test" {
194+
project_id = var.project_id
195+
provider_name = "AWS"
196+
vendor = "MSK"
197+
arn = aws_msk_cluster.example.arn
198+
}
199+
200+
data "mongodbatlas_stream_privatelink_endpoint" "singular_datasource" {
201+
project_id = var.project_id
202+
id = mongodbatlas_stream_privatelink_endpoint.test.id
203+
}
204+
205+
output "privatelink_endpoint_id" {
206+
value = data.mongodbatlas_stream_privatelink_endpoint.singular_datasource.id
207+
}
208+
```
209+
82210
<!-- schema generated by tfplugindocs -->
83211
## Schema
84212

@@ -91,14 +219,15 @@ output "interface_endpoint_ids" {
91219

92220
### Read-Only
93221

222+
- `arn` (String) Amazon Resource Name (ARN).
94223
- `dns_domain` (String) Domain name of Privatelink connected cluster.
95224
- `dns_sub_domain` (List of String) Sub-Domain name of Confluent cluster. These are typically your availability zones.
96225
- `error_message` (String) Error message if the connection is in a failed state.
97226
- `interface_endpoint_id` (String) Interface endpoint ID that is created from the specified service endpoint ID.
98227
- `interface_endpoint_name` (String) Name of interface endpoint that is created from the specified service endpoint ID.
99228
- `provider_account_id` (String) Account ID from the cloud provider.
100229
- `provider_name` (String) Provider where the Kafka cluster is deployed.
101-
- `region` (String) Domain name of Confluent cluster.
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`.
102231
- `service_endpoint_id` (String) Service Endpoint ID.
103232
- `state` (String) Status of the connection.
104233
- `vendor` (String) Vendor who manages the Kafka cluster.

docs/data-sources/stream_privatelink_endpoints.md

Lines changed: 130 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
`mongodbatlas_stream_privatelink_endpoints` describes a Privatelink Endpoint for Streams.
44

55
## Example Usages
6+
7+
### AWS Confluent Privatelink
68
```terraform
79
resource "confluent_environment" "staging" {
810
display_name = "Staging"
@@ -79,6 +81,132 @@ output "interface_endpoint_ids" {
7981
}
8082
```
8183

84+
### AWS MSK Privatelink
85+
```terraform
86+
resource "aws_vpc" "vpc" {
87+
cidr_block = "192.168.0.0/22"
88+
}
89+
90+
data "aws_availability_zones" "azs" {
91+
state = "available"
92+
}
93+
94+
resource "aws_subnet" "subnet_az1" {
95+
availability_zone = data.aws_availability_zones.azs.names[0]
96+
cidr_block = "192.168.0.0/24"
97+
vpc_id = aws_vpc.vpc.id
98+
}
99+
100+
resource "aws_subnet" "subnet_az2" {
101+
availability_zone = data.aws_availability_zones.azs.names[1]
102+
cidr_block = "192.168.1.0/24"
103+
vpc_id = aws_vpc.vpc.id
104+
}
105+
106+
resource "aws_security_group" "sg" {
107+
vpc_id = aws_vpc.vpc.id
108+
}
109+
110+
resource "aws_msk_cluster" "example" {
111+
cluster_name = var.msk_cluster_name
112+
kafka_version = "3.6.0"
113+
number_of_broker_nodes = 2
114+
115+
broker_node_group_info {
116+
instance_type = "kafka.m5.large"
117+
client_subnets = [
118+
aws_subnet.subnet_az1.id,
119+
aws_subnet.subnet_az2.id,
120+
]
121+
security_groups = [aws_security_group.sg.id]
122+
123+
connectivity_info {
124+
vpc_connectivity {
125+
client_authentication {
126+
sasl {
127+
scram = true
128+
}
129+
}
130+
}
131+
}
132+
}
133+
134+
client_authentication {
135+
sasl {
136+
scram = true
137+
}
138+
}
139+
140+
configuration_info {
141+
arn = aws_msk_configuration.example.arn
142+
revision = aws_msk_configuration.example.latest_revision
143+
}
144+
}
145+
146+
resource "aws_msk_cluster_policy" "example" {
147+
cluster_arn = aws_msk_cluster.example.arn
148+
149+
policy = jsonencode({
150+
Version = "2012-10-17",
151+
Statement = [{
152+
Effect = "Allow"
153+
Principal = {
154+
"AWS" = "arn:aws:iam::${var.aws_account_id}:root"
155+
}
156+
Action = [
157+
"kafka:CreateVpcConnection",
158+
"kafka:GetBootstrapBrokers",
159+
"kafka:DescribeCluster",
160+
"kafka:DescribeClusterV2"
161+
]
162+
Resource = aws_msk_cluster.example.arn
163+
}]
164+
})
165+
}
166+
167+
resource "aws_msk_single_scram_secret_association" "example" {
168+
cluster_arn = aws_msk_cluster.example.arn
169+
secret_arn = var.aws_secret_arn
170+
}
171+
172+
resource "aws_msk_configuration" "example" {
173+
name = "${var.msk_cluster_name}-msk-configuration"
174+
175+
# Default ASW MSK configuration with "allow.everyone.if.no.acl.found=false" added
176+
server_properties = <<PROPERTIES
177+
auto.create.topics.enable=false
178+
default.replication.factor=3
179+
min.insync.replicas=2
180+
num.io.threads=8
181+
num.network.threads=5
182+
num.partitions=1
183+
num.replica.fetchers=2
184+
replica.lag.time.max.ms=30000
185+
socket.receive.buffer.bytes=102400
186+
socket.request.max.bytes=104857600
187+
socket.send.buffer.bytes=102400
188+
unclean.leader.election.enable=true
189+
allow.everyone.if.no.acl.found=false
190+
PROPERTIES
191+
}
192+
193+
resource "mongodbatlas_stream_privatelink_endpoint" "test" {
194+
project_id = var.project_id
195+
provider_name = "AWS"
196+
vendor = "MSK"
197+
arn = aws_msk_cluster.example.arn
198+
}
199+
200+
data "mongodbatlas_stream_privatelink_endpoint" "singular_datasource" {
201+
project_id = var.project_id
202+
id = mongodbatlas_stream_privatelink_endpoint.test.id
203+
}
204+
205+
output "privatelink_endpoint_id" {
206+
value = data.mongodbatlas_stream_privatelink_endpoint.singular_datasource.id
207+
}
208+
```
209+
82210
<!-- schema generated by tfplugindocs -->
83211
## Schema
84212

@@ -97,6 +225,7 @@ output "interface_endpoint_ids" {
97225

98226
Read-Only:
99227

228+
- `arn` (String) Amazon Resource Name (ARN).
100229
- `dns_domain` (String) Domain name of Privatelink connected cluster.
101230
- `dns_sub_domain` (List of String) Sub-Domain name of Confluent cluster. These are typically your availability zones.
102231
- `error_message` (String) Error message if the connection is in a failed state.
@@ -108,7 +237,7 @@ Read-Only:
108237
**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.
109238
- `provider_account_id` (String) Account ID from the cloud provider.
110239
- `provider_name` (String) Provider where the Kafka cluster is deployed.
111-
- `region` (String) Domain name of Confluent cluster.
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`.
112241
- `service_endpoint_id` (String) Service Endpoint ID.
113242
- `state` (String) Status of the connection.
114243
- `vendor` (String) Vendor who manages the Kafka cluster.

0 commit comments

Comments
 (0)