terraform-aws-modules / terraform-aws-msk-kafka-cluster

Terraform module to create AWS MSK (Managed Streaming for Kafka) resources 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/msk-kafka-cluster/aws
Apache License 2.0
55 stars 54 forks source link

Cannot correctly import MSK configuration #39

Open ajax-koval-i opened 2 weeks ago

ajax-koval-i commented 2 weeks ago

Description

In your module, the resources aws_msk_configuration and random_id are used.

If the aws_msk_configuration resource was created manually or by another module and was given a simple name, for example, example-configuration, when importing this resource into your module, the aws_msk_configuration will always be recreated since you use the random_id resource in the configuration name.

It would be great to have the option to correctly import resources into your public module.

For example, by adding the ability to disable the random-id suffix at the end of the name.

Versions

Reproduction Code [Required]

  1. State list

    Screenshot 2024-08-28 at 18 27 36
  2. Importing resource aws_msk_configuration.this[0] command: terragrunt import 'aws_msk_configuration.this[0]' arn:aws:kafka:eu-west-3:xxxxxxxxxxxx:configuration/xxxxx-xxxxxx/xxxxxxxx-xxxx-4ddb-9f0f-5785e60adbd6-3

    Screenshot 2024-08-28 at 18 32 01

    Import successful

  3. terragrunt plan comand output:

    edited

Force replacement here (recreate of the resource).

  1. Block of code for aws_msk_configuration: edited too

NAMES ARE IDENTICAL (in code, and in aws) Forces replacement here only for one reason - you added random_id resource at the end of the configuration name Here is permalink

Expected behavior

Adding the ability to omit the random_id resource from the end of the configuration name

Actual behavior

Cannot correctly import resources to public module.

bryantbiggs commented 2 weeks ago

this was intended based on user feedback - without it, if you make a change to the configuration and try to apply it, it fails with a "this resource already exists" message. so the random part was added to allow folks to modify the configs and apply it.

If you are importing, I would suggest letting Terraform replace the configs and you're now adopted into the module. If you want to modify this config in the future, you'll inevitably face this issue

bryantbiggs commented 2 weeks ago

see #17