Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Msk #177

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft

Msk #177

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/public-dns-external/custom.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
cloud {
organization = "weights-and-biases"
workspaces {
name = "apple-replica-msk"
}
}
}
9 changes: 9 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module "networking" {
elasticache_subnet_cidrs = var.network_elasticache_subnet_cidrs
}


locals {
network_id = var.create_vpc ? module.networking.vpc_id : var.network_id
network_public_subnets = var.create_vpc ? module.networking.public_subnets : var.network_public_subnets
Expand All @@ -59,6 +60,14 @@ locals {
network_elasticache_subnet_group_name = module.networking.elasticache_subnet_group_name
}

module "msk" {
source = "./modules/msk"
namespace = var.namespace

private_subnets = local.network_private_subnets
vpc_id = local.network_id
}

module "database" {
source = "./modules/database"

Expand Down
56 changes: 56 additions & 0 deletions modules/msk/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Security group for MSK (allows traffic within your VPC)
resource "aws_security_group" "msk" {
name = "${var.namespace}-msk-sg"
vpc_id = var.vpc_id
description = "Allow MSK traffic within the VPC"

ingress {
from_port = 9092
to_port = 9092
protocol = "tcp"
self = true
}

egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}

resource "aws_msk_cluster" "default" {
cluster_name = var.namespace
kafka_version = var.kafka_version
number_of_broker_nodes = length(var.private_subnets)

broker_node_group_info {
instance_type = var.instance_type

client_subnets = var.private_subnets
security_groups = [aws_security_group.msk.id]

storage_info {
ebs_storage_info {
volume_size = var.volume_size
}
}
}

encryption_info {
encryption_in_transit {
client_broker = "TLS"
}
}

depends_on = [aws_security_group.msk]
}

output "zookeeper_connect_string" {
value = aws_msk_cluster.default.zookeeper_connect_string
}

output "bootstrap_brokers_tls" {
description = "TLS connection host:port pairs"
value = aws_msk_cluster.default.bootstrap_brokers_tls
}
26 changes: 26 additions & 0 deletions modules/msk/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
variable "namespace" {
type = string
}

variable "vpc_id" {
type = string
}

variable "private_subnets" {
type = list(string)
}

variable "instance_type" {
type = string
default = "kafka.m5.large"
}

variable "volume_size" {
type = number
default = 20
}

variable "kafka_version" {
type = string
default = "3.6.0"
}
Loading