fluxcd / terraform-provider-flux

Terraform and OpenTofu provider for bootstrapping Flux
https://registry.terraform.io/providers/fluxcd/flux/latest
Apache License 2.0
336 stars 89 forks source link

[Bug]: Changing Flux repo branch fails to update the deployed Flux-system Gitrepository resource #653

Closed kcighon closed 4 weeks ago

kcighon commented 1 month ago

Describe the bug

We have recently started using the terraform provider instead of the cli.

We use a branching strategy when updating our flux repo. We branch off main, make our changes, re-bootstrap the cluster off the new branch and test the changes.

When using flux cli, both the flux-system Gitrepository resource and the yaml in the git repository is updated to the new target branch.

Using the terraform provider, terraform recognizes the need to update, the yaml in the git repository is updated however the flux-system Gitrepository resource on the cluster is not.

Steps to reproduce

terraform {
  required_providers {
    flux = {
      source = "fluxcd/flux"
      version = "1.2.3"
    }
  }
}

provider "flux" {
  kubernetes = {
    config_path = "~/.kube/config"
  }
  git = {
    url = var.git_url
    branch = var.git_branch

    # configure credentials
  }
}

resource "flux_bootstrap_git" "this" {
  path = var.cluster_path

  manifests_path = "${path.cwd}/manifests"
  registry             = var.registry
  version             = "v2.2.3"
}

Expected behavior

flux_bootstrap_git should update the cluster flux-system Gitrepository to use new branch in the same way flux cli does.

Screenshots and recordings

No response

Terraform and provider versions

Terraform v1.7.3 fluxcd/flux Provider v1.2.3

Terraform provider configurations

terraform { required_providers { flux = { source = "fluxcd/flux" version = "1.2.3" } } }

flux_bootstrap_git resource

resource "flux_bootstrap_git" "this" { path = var.cluster_path

manifests_path = "${path.cwd}/manifests" registry = var.registry version = "v2.2.3" }

Flux version

v2.2.3

Additional context

No response

Code of Conduct

Would you like to implement a fix?

None