Delete a connector

Deleting a connector permanently removes it from the Connect cluster. This action stops the flow of data between the source and target systems. Ensure you understand the implications for your data pipeline before deleting a connector.

To delete a connector in a Connect cluster, you can use the Google Cloud console, the gcloud CLI, the Managed Service for Apache Kafka client library, or the Managed Kafka API. You can't use the open source Apache Kafka API to delete connectors.

Required roles and permissions to delete a connector

To get the permissions that you need to delete a connector, ask your administrator to grant you the Managed Kafka Connector Editor ( roles/managedkafka.connectorEditor ) IAM role on the project containing the Connect cluster. For more information about granting roles, see Manage access to projects, folders, and organizations .

This predefined role contains the permissions required to delete a connector. To see the exact permissions that are required, expand the Required permissionssection:

Required permissions

The following permissions are required to delete a connector:

  • Grant the delete connector permission on the requested connector: managedkafka.connectors.delete
  • Grant the list connectors permission on the Connect cluster containing the connector. This is only required for console deletion: managedkafka.connectors.list

You might also be able to get these permissions with custom roles or other predefined roles .

For more information about the Managed Kafka Connector Editor role, see Managed Service for Apache Kafka predefined roles .

Delete a connector

Console

  1. In the Google Cloud console, go to the Connect Clusterspage.

    Go to Connect Clusters

  2. Click the Connect cluster that hosts the connector that you want to delete.

    The Connect cluster detailspage is displayed.

  3. On the Resourcestab, find the connector in the list and click its name.

    You are redirected to the Connector detailspage.

  4. Click Delete.

gcloud

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. Use the gcloud managed-kafka connectors delete command to delete a connector:

     gcloud  
    managed-kafka  
    connectors  
    delete  
     CONNECTOR_ID 
      
     \ 
      
    --location = 
     LOCATION 
      
     \ 
      
    --connect-cluster = 
     CONNECT_CLUSTER_ID 
     
    

    Replace the following:

    • CONNECTOR_ID : Required. The ID of the connector you want to delete.
    • LOCATION : Required. The location of the Connect cluster containing the connector.
    • CONNECT_CLUSTER_ID : Required. The ID of the Connect cluster containing the connector.

    Example command:

     gcloud  
    managed-kafka  
    connectors  
    delete  
    test-connector  
     \ 
      
    --location = 
    us-central1  
     \ 
      
    --connect-cluster = 
    test-connect-cluster 
    

Go

Before trying this sample, follow the Go setup instructions in Install the client libraries . For more information, see the Managed Service for Apache Kafka Go API reference documentation .

To authenticate to Managed Service for Apache Kafka, set up Application Default Credentials(ADC). For more information, see Set up ADC for a local development environment .

  import 
  
 ( 
  
 "context" 
  
 "fmt" 
  
 "io" 
  
 "cloud.google.com/go/managedkafka/apiv1/managedkafkapb" 
  
 "google.golang.org/api/option" 
  
 managedkafka 
  
 "cloud.google.com/go/managedkafka/apiv1" 
 ) 
 func 
  
 deleteConnector 
 ( 
 w 
  
 io 
 . 
 Writer 
 , 
  
 projectID 
 , 
  
 region 
 , 
  
 connectClusterID 
 , 
  
 connectorID 
  
 string 
 , 
  
 opts 
  
 ... 
 option 
 . 
 ClientOption 
 ) 
  
 error 
  
 { 
  
 // projectID := "my-project-id" 
  
 // region := "us-central1" 
  
 // connectClusterID := "my-connect-cluster" 
  
 // connectorID := "my-connector" 
  
 ctx 
  
 := 
  
 context 
 . 
 Background 
 () 
  
 client 
 , 
  
 err 
  
 := 
  
 managedkafka 
 . 
 NewManagedKafkaConnectClient 
 ( 
 ctx 
 , 
  
 opts 
 ... 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 return 
  
 fmt 
 . 
 Errorf 
 ( 
 "managedkafka.NewManagedKafkaConnectClient got err: %w" 
 , 
  
 err 
 ) 
  
 } 
  
 defer 
  
 client 
 . 
 Close 
 () 
  
 connectorPath 
  
 := 
  
 fmt 
 . 
 Sprintf 
 ( 
 "projects/%s/locations/%s/connectClusters/%s/connectors/%s" 
 , 
  
 projectID 
 , 
  
 region 
 , 
  
 connectClusterID 
 , 
  
 connectorID 
 ) 
  
 req 
  
 := 
  
& managedkafkapb 
 . 
 DeleteConnectorRequest 
 { 
  
 Name 
 : 
  
 connectorPath 
 , 
  
 } 
  
 err 
  
 = 
  
 client 
 . 
 DeleteConnector 
 ( 
 ctx 
 , 
  
 req 
 ) 
  
 if 
  
 err 
  
 != 
  
 nil 
  
 { 
  
 return 
  
 fmt 
 . 
 Errorf 
 ( 
 "client.DeleteConnector got err: %w" 
 , 
  
 err 
 ) 
  
 } 
  
 fmt 
 . 
 Fprint 
 ( 
 w 
 , 
  
 "Deleted connector\n" 
 ) 
  
 return 
  
 nil 
 } 
 

Java

Before trying this sample, follow the Java setup instructions in Install the client libraries . For more information, see the Managed Service for Apache Kafka Java API reference documentation .

To authenticate to Managed Service for Apache Kafka, set up Application Default Credentials. For more information, see Set up ADC for a local development environment .

  import 
  
 com.google.api.gax.rpc. ApiException 
 
 ; 
 import 
  
 com.google.cloud.managedkafka.v1. ConnectorName 
 
 ; 
 import 
  
 com.google.cloud.managedkafka.v1. ManagedKafkaConnectClient 
 
 ; 
 import 
  
 java.io.IOException 
 ; 
 public 
  
 class 
 DeleteConnector 
  
 { 
  
 public 
  
 static 
  
 void 
  
 main 
 ( 
 String 
 [] 
  
 args 
 ) 
  
 throws 
  
 Exception 
  
 { 
  
 // TODO(developer): Replace these variables before running the example. 
  
 String 
  
 projectId 
  
 = 
  
 "my-project-id" 
 ; 
  
 String 
  
 region 
  
 = 
  
 "my-region" 
 ; 
  
 // e.g. us-east1 
  
 String 
  
 clusterId 
  
 = 
  
 "my-connect-cluster" 
 ; 
  
 String 
  
 connectorId 
  
 = 
  
 "my-connector" 
 ; 
  
 deleteConnector 
 ( 
 projectId 
 , 
  
 region 
 , 
  
 clusterId 
 , 
  
 connectorId 
 ); 
  
 } 
  
 public 
  
 static 
  
 void 
  
 deleteConnector 
 ( 
  
 String 
  
 projectId 
 , 
  
 String 
  
 region 
 , 
  
 String 
  
 clusterId 
 , 
  
 String 
  
 connectorId 
 ) 
  
 throws 
  
 IOException 
  
 { 
  
 try 
  
 ( 
  ManagedKafkaConnectClient 
 
  
 managedKafkaConnectClient 
  
 = 
  
  ManagedKafkaConnectClient 
 
 . 
 create 
 ()) 
  
 { 
  
  ConnectorName 
 
  
 name 
  
 = 
  
  ConnectorName 
 
 . 
 of 
 ( 
 projectId 
 , 
  
 region 
 , 
  
 clusterId 
 , 
  
 connectorId 
 ); 
  
 // This operation is handled synchronously. 
  
 managedKafkaConnectClient 
 . 
 deleteConnector 
 ( 
 name 
 ); 
  
 System 
 . 
 out 
 . 
 printf 
 ( 
 "Deleted connector: %s\n" 
 , 
  
 name 
 ); 
  
 } 
  
 catch 
  
 ( 
 IOException 
  
 | 
  
  ApiException 
 
  
 e 
 ) 
  
 { 
  
 System 
 . 
 err 
 . 
 printf 
 ( 
 "managedKafkaConnectClient.deleteConnector got err: %s\n" 
 , 
  
 e 
 . 
  getMessage 
 
 ()); 
  
 } 
  
 } 
 } 
 

Python

Before trying this sample, follow the Python setup instructions in Install the client libraries . For more information, see the Managed Service for Apache Kafka Python API reference documentation .

To authenticate to Managed Service for Apache Kafka, set up Application Default Credentials. For more information, see Set up ADC for a local development environment .

  from 
  
 google.api_core.exceptions 
  
 import 
 GoogleAPICallError 
 from 
  
 google.cloud.managedkafka_v1.services.managed_kafka_connect 
  
 import 
 ( 
  ManagedKafkaConnectClient 
 
 , 
 ) 
 from 
  
 google.cloud 
  
 import 
  managedkafka_v1 
 
 # TODO(developer) 
 # project_id = "my-project-id" 
 # region = "us-central1" 
 # connect_cluster_id = "my-connect-cluster" 
 # connector_id = "my-connector" 
 connect_client 
 = 
 ManagedKafkaConnectClient 
 () 
 request 
 = 
  managedkafka_v1 
 
 . 
  DeleteConnectorRequest 
 
 ( 
 name 
 = 
 connect_client 
 . 
  connector_path 
 
 ( 
 project_id 
 , 
 region 
 , 
 connect_cluster_id 
 , 
 connector_id 
 ), 
 ) 
 try 
 : 
 operation 
 = 
 connect_client 
 . 
  delete_connector 
 
 ( 
 request 
 = 
 request 
 ) 
 print 
 ( 
 f 
 "Waiting for operation 
 { 
 operation 
 . 
 operation 
 . 
 name 
 } 
 to complete..." 
 ) 
 operation 
 . 
 result 
 () 
 print 
 ( 
 "Deleted connector" 
 ) 
 except 
 GoogleAPICallError 
 as 
 e 
 : 
 print 
 ( 
 f 
 "The operation failed with error: 
 { 
 e 
 } 
 " 
 ) 
 
Apache Kafka® is a registered trademark of The Apache Software Foundation or its affiliates in the United States and/or other countries.
Create a Mobile Website
View Site in Mobile | Classic
Share by: