confluent_cluster_link Resource

General Availability

confluent_cluster_link provides a Cluster Link resource that enables creating and deleting Cluster Links on a Kafka cluster on Confluent Cloud.

Example Usage

// https://docs.confluent.io/cloud/current/multi-cloud/cluster-linking/cluster-links-cc.html#create-a-cluster-link-in-bidirectional-mode
resource "confluent_cluster_link" "east-to-west" {
  link_name = "bidirectional-link"
  link_mode = "BIDIRECTIONAL"
  local_kafka_cluster {
    id            = data.confluent_kafka_cluster.east.id
    rest_endpoint = data.confluent_kafka_cluster.east.rest_endpoint
    credentials {
      key    = confluent_api_key.app-manager-east-cluster-api-key.id
      secret = confluent_api_key.app-manager-east-cluster-api-key.secret
    }
  }

  remote_kafka_cluster {
    id                 = data.confluent_kafka_cluster.west.id
    bootstrap_endpoint = data.confluent_kafka_cluster.west.bootstrap_endpoint
    credentials {
      key    = confluent_api_key.app-manager-west-cluster-api-key.id
      secret = confluent_api_key.app-manager-west-cluster-api-key.secret
    }
  }

  lifecycle {
    prevent_destroy = true
  }
}

resource "confluent_cluster_link" "west-to-east" {
  link_name = "bidirectional-link"
  link_mode = "BIDIRECTIONAL"
  local_kafka_cluster {
    id            = data.confluent_kafka_cluster.west.id
    rest_endpoint = data.confluent_kafka_cluster.west.rest_endpoint
    credentials {
      key    = confluent_api_key.app-manager-west-cluster-api-key.id
      secret = confluent_api_key.app-manager-west-cluster-api-key.secret
    }
  }

  remote_kafka_cluster {
    id                 = data.confluent_kafka_cluster.east.id
    bootstrap_endpoint = data.confluent_kafka_cluster.east.bootstrap_endpoint
    credentials {
      key    = confluent_api_key.app-manager-east-cluster-api-key.id
      secret = confluent_api_key.app-manager-east-cluster-api-key.secret
    }
  }

  lifecycle {
    prevent_destroy = true
  }
}

Argument Reference

The following arguments are supported:

Attributes Reference

In addition to the preceding arguments, the following attributes are exported:

Import

You can import a Kafka mirror topic by using the cluster link name, cluster link mode, cluster link connection mode, source (or local for bidirectional cluster links) Kafka cluster ID, and destination (or remote for bidirectional cluster links) Kafka cluster ID, in the format <Cluster link name>/<Cluster link mode>/<Cluster connection mode>/<Source (Local) Kafka cluster ID>/<Destination (Remote) Kafka cluster ID>, for example:

# Option #1 when using source-initiated or destination-initiated cluster links
$ export IMPORT_SOURCE_KAFKA_BOOTSTRAP_ENDPOINT="<source_kafka_bootstrap_endpoint>"
$ export IMPORT_SOURCE_KAFKA_API_KEY="<source_kafka_api_key>"
$ export IMPORT_SOURCE_KAFKA_API_SECRET="<source_kafka_api_secret>"
$ export IMPORT_DESTINATION_KAFKA_REST_ENDPOINT="<destination_kafka_rest_endpoint>"
$ export IMPORT_DESTINATION_KAFKA_API_KEY="<destination_kafka_api_key>"
$ export IMPORT_DESTINATION_KAFKA_API_SECRET="<destination_kafka_api_secret>"
$ terraform import confluent_cluster_link.my_cluster_link my-cluster-link/DESTINATION/OUTBOUND/lkc-abc123/lkc-xyz456
# Option #2 when using bidirectional cluster links
$ export IMPORT_LOCAL_KAFKA_BOOTSTRAP_ENDPOINT="<local_kafka_bootstrap_endpoint>"
$ export IMPORT_LOCAL_KAFKA_API_KEY="<local_kafka_api_key>"
$ export IMPORT_LOCAL_KAFKA_API_SECRET="<local_kafka_api_secret>"
$ export IMPORT_REMOTE_KAFKA_REST_ENDPOINT="<remote_kafka_rest_endpoint>"
$ export IMPORT_REMOTE_KAFKA_API_KEY="<remote_kafka_api_key>"
$ export IMPORT_REMOTE_KAFKA_API_SECRET="<remote_kafka_api_secret>"
$ terraform import confluent_cluster_link.my_cluster_link my-cluster-link/BIDIRECTIONAL/OUTBOUND/lkc-abc123/lkc-xyz456

Getting Started

The following end-to-end examples might help to get started with confluent_cluster_link resource:

See Cluster Linking on Confluent Cloud to learn more about Cluster Linking on Confluent Cloud.