Skip to content

Commit ccaa4d3

Browse files
committed
docs: Add Managed Kafka Connect terraform sample for Clusters
* Add sample code for creating a cluster
1 parent b8bbb15 commit ccaa4d3

File tree

1 file changed

+93
-0
lines changed
  • managedkafka/managedkafka_create_connect_cluster

1 file changed

+93
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
# [START managedkafkaconnect_create_cluster_parent]
18+
resource "google_managed_kafka_cluster" "default" {
19+
project = data.google_project.default.project_id
20+
cluster_id = "my-cluster-id"
21+
location = "us-central1"
22+
capacity_config {
23+
vcpu_count = 3
24+
memory_bytes = 3221225472
25+
}
26+
gcp_config {
27+
access_config {
28+
network_configs {
29+
subnet = google_compute_subnetwork.default.id
30+
}
31+
}
32+
}
33+
}
34+
35+
# [START managedkafka_subnetwork]
36+
resource "google_compute_subnetwork" "default" {
37+
name = "test-subnetwork"
38+
ip_cidr_range = "10.2.0.0/16"
39+
region = "us-central1"
40+
network = google_compute_network.default.id
41+
}
42+
43+
44+
resource "google_compute_network" "default" {
45+
name = "test-network"
46+
auto_create_subnetworks = false
47+
}
48+
# [END managedkafka_subnetwork]
49+
50+
# [START managedkafkaconnect_create_cluster]
51+
resource "google_managed_kafka_connect_cluster" "example-kafka-connect-cluster" {
52+
provider = google-beta
53+
project = data.google_project.default.project_id # Replace this with your project ID in quotes
54+
connect_cluster_id = "my-connect-cluster-id"
55+
location = "us-central1"
56+
kafka_cluster = google_managed_kafka_cluster.default.id
57+
58+
capacity_config {
59+
vcpu_count = 12
60+
memory_bytes = 21474836480
61+
}
62+
63+
gcp_config {
64+
access_config {
65+
network_configs {
66+
primary_subnet = google_compute_subnetwork.default.id
67+
}
68+
}
69+
}
70+
71+
depends_on = [
72+
google_managed_kafka_cluster.example-kafka-cluster
73+
]
74+
}
75+
# [END managedkafkaconnect_create_cluster]
76+
77+
# [START managedkafkaconnect_subnetwork]
78+
resource "google_compute_subnetwork" "default" {
79+
name = "test-subnetwork"
80+
ip_cidr_range = "10.2.0.0/16"
81+
region = "us-central1"
82+
network = google_compute_network.default.id
83+
}
84+
85+
resource "google_compute_network" "default" {
86+
name = "test-network"
87+
auto_create_subnetworks = false
88+
}
89+
# [END managedkafkaconnect_subnetwork]
90+
91+
data "google_project" "default" {
92+
}
93+
# [END managedkafkaconnect_create_cluster_parent]

0 commit comments

Comments
 (0)