Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform state updated with new Chart values after apply errored #828

Closed
jose-ledesma opened this issue Feb 7, 2022 · 4 comments · Fixed by #857
Closed

Terraform state updated with new Chart values after apply errored #828

jose-ledesma opened this issue Feb 7, 2022 · 4 comments · Fixed by #857
Labels

Comments

@jose-ledesma
Copy link

Terraform, Provider, Kubernetes and Helm Versions

Terraform version:  v1.0.5
Provider version: v2.2.0
Kubernetes version: v1.21 (EKS)

Affected Resource(s)

  • helm_release

Terraform Configuration Files

provider "helm" {
  kubernetes {
    host                   = try(module.eks_cluster["cluster1"].output.eks_cluster.endpoint, "")
    cluster_ca_certificate = try(base64decode(module.eks_cluster["cluster1"].output.eks_cluster.certificate_authority.0.data), "")
    token                  = try(data.aws_eks_cluster_auth.cluster["cluster1"].token, "")
  }
}

resource "helm_release" "filebeat" {
  name       = "filebeat"
  repository = "https://helm.elastic.co"
  chart      = "filebeat"
  version    = "~> 7.14.0"

  values = [templatefile("manifests/filebeat.yml.tpl", {
    "key1" : "value1",
    "key2" : "value2",
  })]
}

Debug Output

NOTE: In addition to Terraform debugging, please set HELM_DEBUG=1 to enable debugging info from helm.

Panic Output

Steps to Reproduce

  1. Plan and apply the helm_release
  2. make a modification in the values (Add/change/remove any of the Helm values)
  3. Run terraform plan : with the provider configuration it will retrieve a new token for connecting to the EKS cluster. This token has a 15 minutes lifespan
  4. wait 15 minutes
  5. terraform apply

Terraform apply will fail with:

Error: Kubernetes cluster unreachable: the server has asked for the client to provide credentials
with helm_release.filebeat
on filebeat.tf line 15, in resource "helm_release" "filebeat":
resource "helm_release" "filebeat" {

Nonetheless the Terraform State will be updated with the new Values, and subsequent terraform plan will detect no changes

Expected Behavior

Terraform state should not be updated

Actual Behavior

Terraform state is updated after the failure

Important Factoids

Using Terraform Cloud

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@nfi-opsguru
Copy link

My workaround:

  1. terraform state rm helm_release.$name
  2. terraform import <addr> <namespace>/<release-name>

This is quite a nasty bug IMO.

@imriz
Copy link
Contributor

imriz commented Apr 27, 2022

This is a very nasty bug, and no one even reviewed it over two months later?

@imriz
Copy link
Contributor

imriz commented Apr 27, 2022

Trying to address it in PR #857

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants