Skip to content

Commit

Permalink
Resolve msk configuration resource conflict for replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryfan01234 committed Aug 12, 2024
1 parent d317e62 commit 3464d81
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions indexer/msk.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
resource "aws_msk_configuration" "main" {
kafka_versions = [local.kafka_version]
name = "${var.environment}-${var.indexers[var.region].name}-msk-configuration"
// create_before_destroy=true forces a new name because the old resource not delete first. For now we only trigger
// replacement for new kafka versions, so use the kafka version in the name
name = "${var.environment}-${var.indexers[var.region].name}-msk-configuration-${replace(local.kafka_version, ".", "-")}"
server_properties = <<PROPERTIES
auto.create.topics.enable=false
default.replication.factor=3
Expand All @@ -18,6 +20,11 @@ resource "aws_msk_configuration" "main" {
unclean.leader.election.enable=true
zookeeper.session.timeout.ms=6000
PROPERTIES

lifecycle {
// The msk cluster is using the configuration so we cannot destroy before create (replacement default)
create_before_destroy = true
}
}

resource "aws_msk_cluster" "main" {
Expand Down Expand Up @@ -48,4 +55,4 @@ resource "aws_msk_cluster" "main" {
arn = aws_msk_configuration.main.arn
revision = aws_msk_configuration.main.latest_revision
}
}
}

0 comments on commit 3464d81

Please sign in to comment.