Confluent Provider 2.0.0: Upgrade Guide

Provider Version Configuration

Before reading further, ensure that your environment successfully runs terraform plan without unexpected changes. Run the following command:

terraform plan

Your output should resemble:

confluent_service_account.test-sa: Refreshing state... [id=sa-xyz123]
confluent_environment.test-env: Refreshing state... [id=env-dge456]
confluent_kafka_cluster.basic: Refreshing state... [id=lkc-vrp3op]
data.confluent_schema_registry_region.essentials: Refreshing state... [id=sgreg-4]
...

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
╷
│ Warning: Deprecated Resource
│ 
│   with data.confluent_schema_registry_region.essentials,
│   on main.tf line 20, in data "confluent_schema_registry_region" "essentials":
│   20: data "confluent_schema_registry_region" "essentials" {
│ 
│ The schema_registry_region data source has been deprecated and will be removed in the next major release (2.0.0). 
│ Refer to the Upgrade Guide at https://registry.terraform.io/providers/confluentinc/confluent/latest/docs/guides/version-2-upgrade for more details.
│ 
│ (and 2 more similar warnings elsewhere)

Upgrade Terraform Configuration

Changes to confluent_schema_registry_cluster resource

Deprecated confluent_schema_registry_cluster resource will be removed in version 2.0.0.

Use the confluent_schema_registry_cluster data source instead to avoid Warning: Deprecated Resource messages.

The next step is to upgrade your TF configuration:

Before

<div class="codehilite"><pre><span></span><code><span class="kr">resource</span><span class="w"> </span><span class="nc">&quot;confluent_schema_registry_cluster&quot;</span><span class="w"> </span><span class="nv">&quot;essentials&quot;</span><span class="w"> </span><span class="p">{</span><span class="c1"></span>
<span class="c1">  # ...</span>
<span class="w">  </span><span class="nb">environment</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="na">id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nv">confluent_environment.staging.id</span><span class="w"></span>
<span class="w">  </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>

After

<div class="codehilite"><pre><span></span><code><span class="kr">data</span><span class="w"> </span><span class="nc">&quot;confluent_schema_registry_cluster&quot;</span><span class="w"> </span><span class="nv">&quot;essentials&quot;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="nb">environment</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="na">id</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nv">confluent_environment.staging.id</span><span class="w"></span>
<span class="w">  </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="c1"></span>

<span class="c1"># Also make sure to replace all resource references confluent_schema_registry_cluster.essentials with</span>
<span class="c1"># data.confluent_schema_registry_cluster.essentials</span>
</code></pre></div>

Next, remove the confluent_schema_registry_cluster resource from TF state (again, just from TF state and not from Confluent Cloud).

$ terraform state list | grep confluent_schema_registry_cluster 
$ terraform state rm confluent_schema_registry_cluster.essentials

Your output should resemble:

$ terraform state list | grep confluent_schema_registry_cluster 
confluent_schema_registry_cluster.essentials
$ terraform state rm confluent_schema_registry_cluster.essentials
Removed confluent_schema_registry_cluster.essentials
Successfully removed 1 resource instance(s).

Changes to confluent_schema_registry_region data source

Deprecated confluent_schema_registry_region data source will be removed in version 2.0.0.

Remove the confluent_schema_registry_cluster data source only from TF configuration (as data sources are not stored in the TF state) instead to avoid Warning: Deprecated Resource messages.

To remove confluent_schema_registry_cluster data source from TF configuration, you can just remove its definition:

Before

<div class="codehilite"><pre><span></span><code><span class="kr">data</span><span class="w"> </span><span class="nc">&quot;confluent_stream_governance_region&quot;</span><span class="w"> </span><span class="nv">&quot;essentials&quot;</span><span class="w"> </span><span class="p">{</span><span class="c1"></span>
<span class="c1">  # ...</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>

After

<div class="codehilite"><pre><span></span><code><span class="c1"># empty</span>
</code></pre></div>
Sanity Check

Check that the upgrade was successful by ensuring that your environment successfully runs terraform plan without unexpected changes. Run the following command:

terraform plan

Your output should resemble:

confluent_service_account.test-sa: Refreshing state... [id=sa-xyz123]
confluent_environment.test-env: Refreshing state... [id=env-dge456]
confluent_kafka_cluster.basic: Refreshing state... [id=lkc-vrp3op]
confluent_schema_registry_cluster.essentials: Refreshing state... [id=lsrc-abc123]
confluent_kafka_acl.describe-test-basic-cluster: Refreshing state... [id=lkc-abc123/CLUSTER#kafka-cluster#LITERAL#User:sa-xyz123#*#DESCRIBE#ALLOW]
confluent_kafka_topic.orders: Refreshing state... [id=lkc-abc123/orders]
confluent_kafka_acl.describe-orders: Refreshing state... [id=lkc-abc123/TOPIC#orders#LITERAL#User:sa-xyz123#*#DESCRIBE#ALLOW]
...
No changes. Infrastructure is up-to-date.

without any Warning: Deprecated Resource messages.

If you run into any problems, report an issue to Confluent.