Skip to content

Commit 3a791f0

Browse files
Add Managed Kafka ConnectCluster and Connector resources and tests (#13310) (#21867)
[upstream:069a0fb390a0610836eff8549faa523555a1db03] Signed-off-by: Modular Magician <[email protected]>
1 parent 07bb066 commit 3a791f0

File tree

3 files changed

+482
-0
lines changed

3 files changed

+482
-0
lines changed

.changelog/13310.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```release-note:new-resource
2+
`google_managed_kafka_connect_cluster` (beta)
3+
```
4+
```release-note:new-resource
5+
`google_managed_kafka_connector` (beta)
6+
```
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
---
2+
# ----------------------------------------------------------------------------
3+
#
4+
# *** AUTO GENERATED CODE *** Type: MMv1 ***
5+
#
6+
# ----------------------------------------------------------------------------
7+
#
8+
# This code is generated by Magic Modules using the following:
9+
#
10+
# Configuration: https:#github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/products/managedkafka/ConnectCluster.yaml
11+
# Template: https:#github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/templates/terraform/resource.html.markdown.tmpl
12+
#
13+
# DO NOT EDIT this file directly. Any changes made to this file will be
14+
# overwritten during the next generation cycle.
15+
#
16+
# ----------------------------------------------------------------------------
17+
subcategory: "Managed Kafka"
18+
description: |-
19+
A Managed Service for Kafka Connect cluster.
20+
---
21+
22+
# google_managed_kafka_connect_cluster
23+
24+
A Managed Service for Kafka Connect cluster.
25+
26+
~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
27+
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.
28+
29+
30+
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
31+
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md&cloudshell_working_dir=managedkafka_connect_cluster_basic&open_in_editor=main.tf" target="_blank">
32+
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
33+
</a>
34+
</div>
35+
## Example Usage - Managedkafka Connect Cluster Basic
36+
37+
38+
```hcl
39+
resource "google_compute_network" "mkc_network" {
40+
name = "my-network"
41+
auto_create_subnetworks = false
42+
}
43+
44+
resource "google_compute_subnetwork" "mkc_subnet" {
45+
name = "my-subnetwork"
46+
ip_cidr_range = "10.2.0.0/16"
47+
region = "us-central1"
48+
network = google_compute_network.mkc_network.id
49+
}
50+
51+
resource "google_compute_subnetwork" "mkc_additional_subnet" {
52+
name = "my-additional-subnetwork-0"
53+
ip_cidr_range = "10.3.0.0/16"
54+
region = "us-central1"
55+
network = google_compute_network.mkc_network.id
56+
}
57+
58+
resource "google_managed_kafka_cluster" "gmk_cluster" {
59+
cluster_id = "my-cluster"
60+
location = "us-central1"
61+
capacity_config {
62+
vcpu_count = 3
63+
memory_bytes = 3221225472
64+
}
65+
gcp_config {
66+
access_config {
67+
network_configs {
68+
subnet = "projects/${data.google_project.project.project_id}/regions/us-central1/subnetworks/${google_compute_subnetwork.mkc_subnet.id}"
69+
}
70+
}
71+
}
72+
}
73+
74+
resource "google_managed_kafka_connect_cluster" "example" {
75+
connect_cluster_id = "my-connect-cluster"
76+
kafka_cluster = "projects/${data.google_project.project.project_id}/locations/us-central1/clusters/${google_managed_kafka_cluster.gmk_cluster.cluster_id}"
77+
location = "us-central1"
78+
capacity_config {
79+
vcpu_count = 12
80+
memory_bytes = 21474836480
81+
}
82+
gcp_config {
83+
access_config {
84+
network_configs {
85+
primary_subnet = "projects/${data.google_project.project.project_id}/regions/us-central1/subnetworks/${google_compute_subnetwork.mkc_subnet.id}"
86+
additional_subnets = ["${google_compute_subnetwork.mkc_additional_subnet.id}"]
87+
dns_domain_names = ["${google_managed_kafka_cluster.gmk_cluster.cluster_id}.us-central1.managedkafka-staging.${data.google_project.project.project_id}.cloud-staging.goog"]
88+
}
89+
}
90+
}
91+
labels = {
92+
key = "value"
93+
}
94+
}
95+
96+
data "google_project" "project" {
97+
}
98+
```
99+
100+
## Argument Reference
101+
102+
The following arguments are supported:
103+
104+
105+
* `kafka_cluster` -
106+
(Required)
107+
The name of the Kafka cluster this Kafka Connect cluster is attached to. Structured like: `projects/PROJECT_ID/locations/LOCATION/clusters/CLUSTER_ID`.
108+
109+
* `capacity_config` -
110+
(Required)
111+
A capacity configuration of a Kafka cluster.
112+
Structure is [documented below](#nested_capacity_config).
113+
114+
* `gcp_config` -
115+
(Required)
116+
Configuration properties for a Kafka Connect cluster deployed to Google Cloud Platform.
117+
Structure is [documented below](#nested_gcp_config).
118+
119+
* `location` -
120+
(Required)
121+
ID of the location of the Kafka Connect resource. See https://cloud.google.com/managed-kafka/docs/locations for a list of supported locations.
122+
123+
* `connect_cluster_id` -
124+
(Required)
125+
The ID to use for the Connect Cluster, which will become the final component of the connect cluster's name. This value is structured like: `my-connect-cluster-id`.
126+
127+
128+
<a name="nested_capacity_config"></a>The `capacity_config` block supports:
129+
130+
* `vcpu_count` -
131+
(Required)
132+
The number of vCPUs to provision for the cluster. The minimum is 3.
133+
134+
* `memory_bytes` -
135+
(Required)
136+
The memory to provision for the cluster in bytes. The CPU:memory ratio (vCPU:GiB) must be between 1:1 and 1:8. Minimum: 3221225472 (3 GiB).
137+
138+
<a name="nested_gcp_config"></a>The `gcp_config` block supports:
139+
140+
* `access_config` -
141+
(Required)
142+
The configuration of access to the Kafka Connect cluster.
143+
Structure is [documented below](#nested_gcp_config_access_config).
144+
145+
146+
<a name="nested_gcp_config_access_config"></a>The `access_config` block supports:
147+
148+
* `network_configs` -
149+
(Required)
150+
Virtual Private Cloud (VPC) subnets where IP addresses for the Kafka Connect cluster are allocated. To make the connect cluster available in a VPC, you must specify at least one subnet per network. You must specify between 1 and 10 subnets. Additional subnets may be specified with additional `network_configs` blocks.
151+
Structure is [documented below](#nested_gcp_config_access_config_network_configs).
152+
153+
154+
<a name="nested_gcp_config_access_config_network_configs"></a>The `network_configs` block supports:
155+
156+
* `primary_subnet` -
157+
(Required)
158+
VPC subnet to make available to the Kafka Connect cluster. Structured like: projects/{project}/regions/{region}/subnetworks/{subnet_id}. It is used to create a Private Service Connect (PSC) interface for the Kafka Connect workers. It must be located in the same region as the Kafka Connect cluster. The CIDR range of the subnet must be within the IPv4 address ranges for private networks, as specified in RFC 1918. The primary subnet CIDR range must have a minimum size of /22 (1024 addresses).
159+
160+
* `additional_subnets` -
161+
(Optional)
162+
Additional subnets may be specified. They may be in another region, but must be in the same VPC network. The Connect workers can communicate with network endpoints in either the primary or additional subnets.
163+
164+
* `dns_domain_names` -
165+
(Optional)
166+
Additional DNS domain names from the subnet's network to be made visible to the Connect Cluster. When using MirrorMaker2, it's necessary to add the bootstrap address's dns domain name of the target cluster to make it visible to the connector. For example: my-kafka-cluster.us-central1.managedkafka.my-project.cloud.goog
167+
168+
- - -
169+
170+
171+
* `labels` -
172+
(Optional)
173+
List of label KEY=VALUE pairs to add. Keys must start with a lowercase character and contain only hyphens (-), underscores ( ), lowercase characters, and numbers. Values must contain only hyphens (-), underscores ( ), lowercase characters, and numbers.
174+
**Note**: This field is non-authoritative, and will only manage the labels present in your configuration.
175+
Please refer to the field `effective_labels` for all of the labels present on the resource.
176+
177+
* `project` - (Optional) The ID of the project in which the resource belongs.
178+
If it is not provided, the provider project is used.
179+
180+
181+
## Attributes Reference
182+
183+
In addition to the arguments listed above, the following computed attributes are exported:
184+
185+
* `id` - an identifier for the resource with format `projects/{{project}}/locations/{{location}}/connectClusters/{{connect_cluster_id}}`
186+
187+
* `name` -
188+
The name of the connect cluster. Structured like: `projects/PROJECT_ID/locations/LOCATION/connectClusters/CONNECT_CLUSTER_ID`.
189+
190+
* `create_time` -
191+
The time when the cluster was created.
192+
193+
* `update_time` -
194+
The time when the cluster was last updated.
195+
196+
* `state` -
197+
The current state of the connect cluster. Possible values: `STATE_UNSPECIFIED`, `CREATING`, `ACTIVE`, `DELETING`.
198+
199+
* `terraform_labels` -
200+
The combination of labels configured directly on the resource
201+
and default labels configured on the provider.
202+
203+
* `effective_labels` -
204+
All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.
205+
206+
207+
## Timeouts
208+
209+
This resource provides the following
210+
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
211+
212+
- `create` - Default is 60 minutes.
213+
- `update` - Default is 30 minutes.
214+
- `delete` - Default is 30 minutes.
215+
216+
## Import
217+
218+
219+
ConnectCluster can be imported using any of these accepted formats:
220+
221+
* `projects/{{project}}/locations/{{location}}/connectClusters/{{connect_cluster_id}}`
222+
* `{{project}}/{{location}}/{{connect_cluster_id}}`
223+
* `{{location}}/{{connect_cluster_id}}`
224+
225+
226+
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import ConnectCluster using one of the formats above. For example:
227+
228+
```tf
229+
import {
230+
id = "projects/{{project}}/locations/{{location}}/connectClusters/{{connect_cluster_id}}"
231+
to = google_managed_kafka_connect_cluster.default
232+
}
233+
```
234+
235+
When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), ConnectCluster can be imported using one of the formats above. For example:
236+
237+
```
238+
$ terraform import google_managed_kafka_connect_cluster.default projects/{{project}}/locations/{{location}}/connectClusters/{{connect_cluster_id}}
239+
$ terraform import google_managed_kafka_connect_cluster.default {{project}}/{{location}}/{{connect_cluster_id}}
240+
$ terraform import google_managed_kafka_connect_cluster.default {{location}}/{{connect_cluster_id}}
241+
```
242+
243+
## User Project Overrides
244+
245+
This resource supports [User Project Overrides](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference#user_project_override).

0 commit comments

Comments
 (0)