Currently, I am using "Mongey/kafka" provider and now I have to switch to "confluentinc/confluent" provider with my existing terraform pipeline. How can I do this ?
Steps currently following to switch the provider
Changing the provider in main.tf file and running following command to replace provider
terraform state replace-provider Mongey/kafka confluentinc/confluent
and after that I run
terraform init command to install the new provider
But after that when I am running
terraform plan
it is giving "no schema available for module.iddn_news_cms_kafka_topics.kafka_acl.topic_writer[13] while reading state; this is a bug in terraform and should be reported" error.
Is there any way, I will change the terraform provider without disturbing the existing resources created using terraform pipeline ?
The
terraform state replace-providercommand is intended for switching between providers that are in some way equivalent to one another, such as thehashicorp/googleandhashicorp/google-betaproviders, or when someone forks a provider into their own namespace but remains compatible with the original provider.Mongey/kafkaandconfluentinc/confluentdo both have resource types that seem to represent the same concepts in the remote system:Mongey/kafkaconfluentinc/confluentkafka_aclconfluent_kafka_aclkafka_quotaconfluent_kafka_client_quotakafka_topicconfluent_kafka_topicHowever, despite representing the same concepts in the remote system these resource types have different names and incompatible schemas, so there is no way to migrate directly between them. Terraform has no way to understand which resource types in one provider match with resource types in another, or to understand how to map attributes from one of the resource types onto corresponding attributes of the other.
Instead, I think the best thing to do here would be to ask Terraform to "forget" the objects and then re-import them into the new resource types:
terraform state rm kafka_acl.exampleto ask Terraform to forget about the remote object associated withkafka_acl.example. There is no undo for this action.terraform import confluent_kafka_acl.example OBJECT-IDto bind theOBJECT-ID(as described in the documentation) toconfluent_kafka_acl.example.I suggest practicing this in a non-production environment first so that you can be confident about the behavior of each of these commands, and learn how to translate from whatever ID format the
Mongey/kafkaprovider uses into whatever import ID format theconfluentinc/confluentprovider uses to describe the same objects.