angelabad / terraform-aws-msk-cluster

Terraform module which creates Msk Kafka Cluster on AWS
https://registry.terraform.io/modules/angelabad/msk-cluster/
Apache License 2.0
30 stars 34 forks source link

Error: error creating MSK Configuration: ConflictException: A resource with this name already exists. #22

Closed tomek-cz closed 2 years ago

tomek-cz commented 2 years ago

Hi, I am using version 2.3 of the module.

I am upgrading MSK from 6.2.1 to 6.2.2

The plan shows the cluster changes:

11:31:23    ~ resource "aws_msk_cluster" "this" {
11:31:23        ~ kafka_version                = "2.6.1" -> "2.6.2"
(...)

and the config changes:

11:31:23    # module.my-cluster.module.msk-cluster[0].aws_msk_configuration.this must be replaced
11:31:23  +/- resource "aws_msk_configuration" "this" {
11:31:23        ~ arn               = "arn:aws:kafka:us-east-1:000000000000:configuration/my-cluster-20348934805454097886/29ee75e6-f713-4193-8d01-ea82ef138359-25" -> (known after apply)
11:31:23        ~ id                = "arn:aws:kafka:us-east-1:000000000000:configuration/my-cluster-20348934805454097886/29ee75e6-f713-4193-8d01-ea82ef138359-25" -> (known after apply)
11:31:23        ~ kafka_versions    = [ # forces replacement
11:31:23            - "2.6.1",
11:31:23            + "2.6.2",
11:31:23          ]
11:31:23        ~ latest_revision   = 1 -> (known after apply)
11:31:23          name              = "my-cluster-20348934805454097886"
11:31:23          # (1 unchanged attribute hidden)
11:31:23      }

However, during the apply the cluster would not get upgraded, with the error

11:31:50  │ Error: error creating MSK Configuration: ConflictException: A resource with this name already exists.
11:31:50  │ {
11:31:50  │   RespMetadata: {
11:31:50  │     StatusCode: 409,
11:31:50  │     RequestID: "xxx"
11:31:50  │   },
11:31:50  │   InvalidParameter: "name",
11:31:50  │   Message_: "A resource with this name already exists."
11:31:50  │ }
11:31:50  │ 
11:31:50  │   with module.my-cluster.module.msk-cluster[0].aws_msk_configuration.this,
11:31:50  │   on .terraform/modules/my-cluster.msk-cluster/main.tf line 81, in resource "aws_msk_configuration" "this":
11:31:50  │   81: resource "aws_msk_configuration" "this" {

An upgrade sounds like a very common task. It looks like the module is trying to create the config using the same config name, which won't work.

tomek-cz commented 2 years ago

I can see this is a duplicate of https://github.com/angelabad/terraform-aws-msk-cluster/issues/10. And the issue is fixed by changing the name of the configuration to include kafka version in it. Thanks! Closing it and will upgrade the module i am using to the latest version.

angelabad commented 2 years ago

Hi @tomek-cz , thanks for the info and your interest.