# Errors while upgrading. Getting the right replace-provider command

**URL:** <https://discuss.hashicorp.com/t/errors-while-upgrading-getting-the-right-replace-provider-command/31820>\
**Category:** Terraform\
**Created:** [November 11, 2021, 10:24pm UTC](https://discuss.hashicorp.com/t/errors-while-upgrading-getting-the-right-replace-provider-command/31820 "2021-11-11T22:24:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeForCoffee](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/codeforcoffee/32/23642_2.png) [@CodeForCoffee](https://discuss.hashicorp.com/u/CodeForCoffee)\
**Post date:** [November 11, 2021, 10:24pm UTC](https://discuss.hashicorp.com/t/errors-while-upgrading-getting-the-right-replace-provider-command/31820/1 "2021-11-11T22:24:19Z")

</div>

So bear with me, I’m very new to Terraform. I was given an old code base that was on 0.12. I upgraded the code base to Terraform 1.0.8 and got that working for a CI pipeline, building a new eks cluster, and tearing it down. However I need to upgrade a live public eks cluster, and that has me scratching my head a bit. Because you have to go through the steps of doing all the upgrades one at a time.

Here are the steps I’ve run and where I’m confused on what needs to change.

```auto
terraform init --upgrade -backend-config=../deploy/public/backend.cfg
terraform 0.13upgrade
git commit -am "0.13 upgrade changes"
terraform plan -out outputs/public.plan -var-file ../deploy/public/public.json -var=cloudflare_api_token= *****

```

This leads to several errors like this(lets focus on **incubator** to untangle this knot):

> Error: Provider configuration not present
> 
> To work with data.helm\_repository.incubator its original provider  
> configuration at provider[“[Terraform Registry](http://registry.terraform.io/-/helm)”] is required, but it  
> has been removed. This occurs when a provider configuration is removed while  
> objects created by that provider still exist in the state. Re-add the provider  
> configuration to destroy **data.helm\_repository.incubator** , after which you can  
> remove the provider configuration again.

This is because I’ve removed the data element as part of the demands on upgrading.  
Code in question:

```auto
-data "helm_repository" "incubator" {
- name = "incubator"
- url = "http://storage.googleapis.com/incubator"
-
- depends_on = [
- module.eks_cluster,
- module.eks_operations_nodes,
- module.eks_vpc,
- kubernetes_service_account.tiller_service_account,
- kubernetes_cluster_role_binding.tiller_role_binding
- ]
-}

resource "helm_release" "aws-alb-ingress-controller" {
 
     name = "aws-alb-ingress-controller"
     namespace = "kube-system"
- repository = "incubator"
+ repository = "https://charts.helm.sh/incubator"
     chart = "aws-alb-ingress-controller"
     version = "0.1.7"

resource "helm_release" "aws-alb-ingress-controller" {
         module.eks_cluster,
         module.eks_operations_nodes,
         module.eks_vpc,
- data.helm_repository.incubator,
         aws_security_group.eks_alb_sg,
- aws_security_group.eks_alb_instances_sg
+ aws_security_group.eks_alb_instances_sg,
+ kubernetes_service_account.tiller_service_account,
+ kubernetes_cluster_role_binding.tiller_role_binding
     ]
 }

```

Reading through stack overflow I believe I need to run some magic spell using

**terraform state replace-provider FROM TO**

But I’m a little concerned because I have all my errors are related to provider[“[Terraform Registry](http://registry.terraform.io/-/helm)”] with a different target to destroy.

---

<div class="post-metadata">

**Author:** ![CodeForCoffee](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/codeforcoffee/32/23642_2.png) [@CodeForCoffee](https://discuss.hashicorp.com/u/CodeForCoffee)\
**Post date:** [November 11, 2021, 11:41pm UTC](https://discuss.hashicorp.com/t/errors-while-upgrading-getting-the-right-replace-provider-command/31820/2 "2021-11-11T23:41:10Z")

</div>

Well that was a short lived cry for help. I believe I’ve figured it out. For those that come after,

**terraform state replace-provider “[registry.terraform.io/-/helm](http://registry.terraform.io/-/helm)” '[registry.terraform.io/hashicorp/helm](http://registry.terraform.io/hashicorp/helm)’**

---

<div class="post-metadata">

**Author:** ![CodeForCoffee](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/codeforcoffee/32/23642_2.png) [@CodeForCoffee](https://discuss.hashicorp.com/u/CodeForCoffee)\
**Post date:** [November 11, 2021, 11:50pm UTC](https://discuss.hashicorp.com/t/errors-while-upgrading-getting-the-right-replace-provider-command/31820/3 "2021-11-11T23:50:12Z")

</div>

hmmm… maybe not. Since that lead to.

> Error: rendered manifests contain a resource that already exists.  
> Unable to continue with install: ServiceAccount “aws-alb-ingress-controller” in namespace “kube-system” exists and cannot be imported into the current release:  
> invalid ownership metadata; label validation error:  
> key “[app.kubernetes.io/managed-by](http://app.kubernetes.io/managed-by)” must equal “Helm”:  
> current value is “Tiller”; annotation validation error:  
> missing key “meta.helm.sh/release-name”:  
> must be set to “aws-alb-ingress-controller”;  
> annotation validation error: missing key “meta.helm.sh/release-namespace”:  
> must be set to “kube-system”
> 
> on 03.k8s.tf line 328, in resource “helm\_release” “aws-alb-ingress-controller”:  
> 328: resource “helm\_release” “aws-alb-ingress-controller” {

---

<div class="post-metadata">

**Author:** ![apparentlymart](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/apparentlymart/32/702_2.png) [@apparentlymart](https://discuss.hashicorp.com/u/apparentlymart)\
**Post date:** [November 12, 2021, 2:07am UTC](https://discuss.hashicorp.com/t/errors-while-upgrading-getting-the-right-replace-provider-command/31820/4 "2021-11-12T02:07:25Z")

</div>

Hi @CodeForCoffee,

I see that you managed to figure out the provider naming problem. For folks who might find this in future: `hashicorp` isn’t _always_ the right namespace to use, so it’s worth checking [Terraform Registry](https://registry.terraform.io/) to see which namespace(s) a provider is in. In this case, `hashicorp` is the correct namespace because this is an official provider, but not all providers that existed prior to v0.13 are official and so some might now live in other namespaces managed by their authors.

The error you’re seeing now seems to be coming from the provider itself, rather than from Terraform Core, and unfortunately I’m not familiar enough with Helm or Kubernetes to suggest what’s up here, but it seems like it’s a conflict with something that already exists in your remote system.
