terraform-provider-flux icon indicating copy to clipboard operation
terraform-provider-flux copied to clipboard

Terraform fails to import `flux_bootstrap_git` if `GitRepository` name is not `flux-system`

Open jamiezieziula opened this issue 1 year ago • 5 comments

I am attempting to import my existing flux implementation to the new terraform resource - I am getting the following error: Config:

resource "flux_bootstrap_git" "cluster_deployment" {
  depends_on = [
    github_repository_deploy_key.cluster_deployment
  ]
  path = "cluster/dev"
}

Error:

tf import flux_bootstrap_git.cluster_deployment flux-system
│ Error: Could not get GitRepository flux-system/flux-system
│ 
│ gitrepositories.source.toolkit.fluxcd.io "flux-system" not found 

my existing GitRepository name in my cluster is cluster-deployment, but it appears the import command expects it to be flux-system. Is there anyway to add a parameter to specify the existing gitrepo name?

jamiezieziula avatar Mar 24 '23 01:03 jamiezieziula

Could you try running the following import command instead?

tf import flux_bootstrap_git.cluster_deployment cluster-deployment

phillebaba avatar Mar 29 '23 21:03 phillebaba

Could you try running the following import command instead?

tf import flux_bootstrap_git.cluster_deployment cluster-deployment

i used this import command :

terraform  import -var-file=var_template.tfvars flux_bootstrap_git.this flux-system 

and was getting same error :

Could not get GitRepository flux-system/flux-system

then i added new GitRepository(temporarily) named flux-system and it worked one step ahead but failed next :

Could not get Kustomization flux-system/flux-system

@phillebaba : on trying your suggestion as above , it works for GitRepository and Kustomization (with their original names, not flux-system) but then it fails giving

terraform  import -var-file=var_template.tfvars flux_bootstrap_git.this kconfig
Could not get Deployment kconfig/kustomize-controller 
deployments.apps "kustomize-controller" not found

seems it then looks for deployment in kconfig namespace instead of flux-system

navpreet-securitas avatar Jul 17 '23 19:07 navpreet-securitas

seems that as of now its is not supported to use names except flux-system for gitrepo and kustomization. [Need to be able to specify Kustomization and GitRepository names](https://github.com/fluxcd/terraform-provider-flux/issues/494)

and tf import expect namespace name, not gitrepo name https://github.com/fluxcd/terraform-provider-flux/blob/main/docs/resources/bootstrap_git.md#import

navpreet-securitas avatar Jul 17 '23 19:07 navpreet-securitas

I am having the same issue

yunussandikci avatar Aug 11 '23 15:08 yunussandikci

Hello @jamiezieziula 👋

I hope you're doing well! I'm the newest contributor to this repository, and I'm currently in the process of issue grooming to ensure that all concerns are addressed promptly and efficiently.

I noticed this issue you reported and wanted to check in with you to see if it's still affecting your work. Your feedback is invaluable to us, and any additional insights or updates you can share would be greatly appreciated to help us understand and solve the problem more effectively.

If this issue has been resolved, could you please share how it was fixed? This information could be incredibly helpful to others in the community facing similar problems. It would also allow us to close this issue with a clear resolution. In case the issue is still open and troubling you, let's work together to find a solution. Your satisfaction and the smooth functioning of our project are our top priorities.

Thank you for your time and contributions to our community. Looking forward to your response!

Best regards,

Steve

If you have already bootstrapped your cluster I would highly recommend deploying flux2 using the upstream helm chart, see example here and not using the flux_bootstrap_git resource. This resource expects a fresh cluster and fresh repository which you don't have.

swade1987 avatar Mar 27 '24 21:03 swade1987

Closing due to inactivity, if you want to discuss this further in the future please raise a bug report using this link

swade1987 avatar Apr 09 '24 11:04 swade1987