Skip to content

darzanebor/terraform-yandex-kafka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yandex.Cloud Terraform Kafka Cluster module

Example

module "kafka" {
  source             = "github.com/darzanebor/terraform-yandex-kafka.git"
  name               = "default"
  environment        = "PRODUCTION"
  network_id         = "my-network-id"
  subnet_ids         = ["my-subnet-id-a",]

  vpc_security_groups = []
  create_default_security_group = true

  config = {
      version       = "2.8"
      brokers_count = 1
      zones         = ["ru-central1-a",]
      assign_public_ip = false
      unmanaged_topics = false
      schema_registry  = false

      resources = {
        resource_preset_id = "s2.medium"
        disk_type_id = "network-ssd"
        disk_size    = 128
      }

      kafka_config = {
          compression_type                = "COMPRESSION_TYPE_ZSTD"
          log_flush_interval_messages     = 1024
          log_flush_interval_ms           = 1000
          log_flush_scheduler_interval_ms = 1000
          log_retention_bytes             = 1073741824
          log_retention_hours             = 168
          log_retention_minutes           = 10080
          log_retention_ms                = 86400000
          log_segment_bytes               = 134217728
          log_preallocate                 = false
          num_partitions                  = 10
          default_replication_factor      = 1
          auto_create_topics_enable       = false
      }

      zookeeper = {
          resource_preset_id = "s2.micro"
          disk_type_id = "network-ssd"
          disk_size = 20
      }
  }
  users = [
    {
      name     = "producer-application"
      password = "password"
      permissions = [
        {
          topic_name = "input"
          role = "ACCESS_ROLE_PRODUCER"
        },
        {
          topic_name = "output"
          role = "ACCESS_ROLE_PRODUCER"
        },
      ]
    },
    {
      name     = "producer-consumer"
      password = "password"
      permissions = [
        {
          topic_name = "input"
          role = "ACCESS_ROLE_PRODUCER"
        }
      ]
    },
  ]
  topics = [{
      name               = "input"
      partitions         = 4
      replication_factor = 1
      config = {
        cleanup_policy        = "CLEANUP_POLICY_COMPACT"
        compression_type      = "COMPRESSION_TYPE_LZ4"
        delete_retention_ms   = 86400000
        file_delete_delay_ms  = 60000
        flush_messages        = 128
        flush_ms              = 1000
        min_compaction_lag_ms = 0
        retention_bytes       = 10737418240
        retention_ms          = 604800000
        max_message_bytes     = 1048588
        min_insync_replicas   = 1
        segment_bytes         = 268435456
        preallocate           = false  
      }
  },
  {
    name               = "output"
    partitions         = 4
    replication_factor = 1
  }]

  default_security_group_ingress = [
    {
      protocol       = "TCP"
      description    = "Allow All ingress."
      v4_cidr_blocks = ["0.0.0.0/0"]
      port           = -1
    },
  ]

  default_security_group_egress = [
    {
      protocol       = "ANY"
      description    = "Allow All egress."
      v4_cidr_blocks = ["0.0.0.0/0"]
      from_port      = -1
      to_port        = -1
    },
  ]
}

Requirements

Name Version
yandex >= 0.13

Providers

Name Version
yandex >= 0.13

Modules

No modules.

Resources

Name Type
yandex_mdb_kafka_cluster.this resource
yandex_mdb_kafka_topic.this resource
yandex_vpc_security_group.this resource

Inputs

Name Description Type Default Required
config (Required) Configuration of the Kafka cluster. The structure is documented below. map {} no
create_default_security_group (Optional) - Create default security group. bool false no
default_security_group_egress (Optional) - A list of egress rules to create with default security group. list [] no
default_security_group_ingress (Optional) - A list of ingress rules to create with default security group. list [] no
environment (Optional) Deployment environment of the Kafka cluster. Can be either PRESTABLE or PRODUCTION. string "PRODUCTION" no
name (Required) Cluster name. any n/a yes
network_id (Required) ID of the network, to which the Kafka cluster belongs. any n/a yes
subnet_ids (Optional) IDs of the subnets, to which the Kafka cluster belongs. any null no
topics (Optional) Kafka topics to create with configuration. list [] no
users (Optional) A user of the Kafka cluster. list [] no
vpc_security_groups (Optional) - Assign security groups to instance. list [] no

Outputs

Name Description
yandex_mdb_kafka_cluster n/a
yandex_mdb_kafka_topic n/a