Skip to content

Commit b5218d8

Browse files
authored
Outline steps for correctly creating and using a KC cluster secret (#119)
1 parent ecc005f commit b5218d8

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

modules/manage/pages/api/cloud-dataplane-api.adoc

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,34 @@ Use the API to configure your xref:develop:managed-connectors/index.adoc[Kafka C
152152

153153
NOTE: Kafka Connect is supported in BYOC and Dedicated clusters only.
154154

155+
==== Create a Kafka Connect cluster secret
156+
157+
Kafka Connect cluster secret data must first be in JSON format, and then Base64-encoded.
158+
159+
. Prepare the secret data in JSON format:
160+
+
161+
```
162+
{"secret.access.key": "<secret-access-key-value>"}
163+
```
164+
165+
. Encode the secret data in Base64:
166+
+
167+
```
168+
echo '{"secret.access.key": "<secret-access-key-value>"}' | base64
169+
```
170+
171+
. Use the xref:api:ROOT:cloud-api.adoc#post-/v1alpha2/kafka-connect/clusters/-cluster_name-/secrets[Secrets API] to create a secret that stores the Base64-encoded secret data:
172+
+
173+
[,bash]
174+
----
175+
curl -X POST "https://<dataplane-api-url>/v1alpha2/kafka-connect/clusters/redpanda/secrets" \
176+
-H 'accept: application/json'\
177+
-H 'content-type: application/json' \
178+
-d '{"name":"<connector-name>","secret_data":"<secret-data-base64-encoded>"}'
179+
----
180+
181+
The response returns an `id` that you can use to <<create-a-kafka-connect-connector,create the Kafka Connect connector>>.
182+
155183
==== Create a Kafka Connect connector
156184

157185
To create a connector, make a POST request to xref:api:ROOT:cloud-api.adoc#post-/v1alpha2/kafka-connect/clusters/-cluster_name-/connectors[`/v1alpha2/kafka-connect/clusters/\{cluster_name}/connectors`].
@@ -164,24 +192,14 @@ curl -X POST "<dataplane-api-url>/v1alpha2/kafka-connect/clusters/redpanda/conne
164192
-H "Authorization: Bearer <token>" \
165193
-H "accept: application/json" \
166194
-H "content-type: application/json" \
167-
-d '{"config":{"connector.class":"com.redpanda.kafka.connect.s3.S3SinkConnector","topics":"test-topic","aws.secret.access.key":"${secretsManager:<secret-id>}","aws.s3.bucket.name":"bucket-name","aws.access.key.id":"access-key","aws.s3.bucket.check":"false","region":"us-east-1"},"name":"my-connector"}'
195+
-d '{"config":{"connector.class":"com.redpanda.kafka.connect.s3.S3SinkConnector","topics":"test-topic","aws.secret.access.key":"${secretsManager:<secret-id>:secret.access.key}","aws.s3.bucket.name":"bucket-name","aws.access.key.id":"access-key","aws.s3.bucket.check":"false","region":"us-east-1"},"name":"my-connector"}'
168196
----
169197

170198
[CAUTION]
171199
====
172-
The field `aws.secret.access.key` in the example contains sensitive information that usually shouldn't be added to a configuration directly. Use the xref:api:ROOT:cloud-api.adoc#post-/v1alpha2/kafka-connect/clusters/-cluster_name-/secrets[Secrets API] to create a secret that stores the Base64-encoded value of the key. You can then use the secret ID to inject the value of the secret in your request.
173-
174-
To create a secret that you can reference in the connector configuration request:
175-
176-
[,bash]
177-
----
178-
curl -X POST "https://<dataplane-api-url>/v1alpha2/kafka-connect/clusters/redpanda/secrets" \
179-
-H 'accept: application/json'\
180-
-H 'content-type: application/json' \
181-
-d '{"name":"<connector-name>","secret_data":"<secret-value-base64-encoded>"}'
182-
----
200+
The field `aws.secret.access.key` in this example contains sensitive information that usually shouldn't be added to a configuration directly. Redpanda recommends that you first create a secret and then use the secret ID to inject the secret in your Create Connector request.
183201
184-
Use the `id` returned in the Create Secret response to replace the placeholder `<secret-id>` in the previous Create Connector example. The syntax `${secretsManager:<secret-id>}` tells the Kafka Connect cluster to load `<secret-id>`.
202+
If you had created a secret following the example from the previous section <<create-a-kafka-connect-cluster-secret,Create a Kafka Connect cluster secret>>, use the `id` returned in the Create Secret response to replace the placeholder `<secret-id>` in this Create Connector example. The syntax `${secretsManager:<secret-id>:secret.access.key}` tells the Kafka Connect cluster to load `<secret-id>`, specifying the key `secret.access.key` from the secret JSON.
185203
====
186204

187205
Example success response:

0 commit comments

Comments
 (0)