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

No kubeconfig when importing an ovh_cloud_project_kube resource #314

Closed
rverchere opened this issue Sep 22, 2022 · 5 comments
Closed

No kubeconfig when importing an ovh_cloud_project_kube resource #314

rverchere opened this issue Sep 22, 2022 · 5 comments
Labels

Comments

@rverchere
Copy link

Terraform Version

$ terraform version   
Terraform v1.2.8
on linux_amd64
+ provider registry.terraform.io/gavinbunney/kubectl v1.14.0
+ provider registry.terraform.io/hashicorp/helm v2.6.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.13.1
+ provider registry.terraform.io/hashicorp/local v2.2.3
+ provider registry.terraform.io/ovh/ovh v0.21.0
+ provider registry.terraform.io/rancher/rancher2 v1.24.1
+ provider registry.terraform.io/terraform-provider-openstack/openstack v1.48.0

Affected Resource(s)

  • ovh_cloud_project_kube

Terraform Configuration Files

resource "ovh_cloud_project_kube" "k8s_cluster" {
  service_name = var.ovh_service_name
  name         = var.k8s_cluster_name
  region       = var.ovh_region_name
  version      = var.k8s_cluster_version
  private_network_id = "${var.ovh_private_network_id}" != "" ? "${var.ovh_private_network_id}" : null
}

resource "local_file" "kubeconfig" {
  content               = ovh_cloud_project_kube.k8s_cluster.kubeconfig
  filename             = "${path.root}/../kubeconfig-${ovh_cloud_project_kube.k8s_cluster.id}.yml"
  file_permission      = "0644"
  directory_permission = "0755"
}

Debug Output

$ terraform import module.kubernetes-ovh-cluster.ovh_cloud_project_kube.k8s_cluster <id-project>/<id-cluster>
module.kubernetes-ovh-cluster.ovh_cloud_project_kube.k8s_cluster: Importing from ID "<id-project>/<id-cluster>"...
module.kubernetes-ovh-cluster.ovh_cloud_project_kube.k8s_cluster: Import prepared!
  Prepared ovh_cloud_project_kube for import
module.kubernetes-ovh-cluster.ovh_cloud_project_kube.k8s_cluster: Refreshing state... [id=<id-project>/<id-cluster>]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

$ terraform plan -out="tfplan.out"                                                                                                                       

module.kubernetes-ovh-cluster.ovh_cloud_project_kube.k8s_cluster: Refreshing state... [id=<id-project>/<id-cluster>]
╷
│ Error: Invalid combination of arguments
│ 
│   with module.kubernetes-ovh-cluster.local_file.kubeconfig,
│   on .terraform/modules/kubernetes-ovh-cluster/main.tf line 21, in resource "local_file" "kubeconfig":
│   21: resource "local_file" "kubeconfig" {
│ 
│ "sensitive_content": one of `content,content_base64,sensitive_content,source` must be specified

Expected Behavior

The kubeconfig resource should exist.

Actual Behavior

The kubeconfig resource is missing.

Steps to Reproduce

  1. terraform import
  2. terraform plan with a resource using the kubeconfig resource

Important Factoids

The kubeconfig resource exists when creating a ovh_cloud_project_kube, not when importing it.

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

@scraly
Copy link
Collaborator

scraly commented Sep 23, 2022

Thanks for opening this issue :).
We fixed it through the PR #315.
It will be release in the v0.22.

@rverchere
Copy link
Author

Thanks!

@scraly
Copy link
Collaborator

scraly commented Oct 6, 2022

Hi,
The new version of the provider have ben released, so now this bug should be fixed :)

@scraly scraly closed this as completed Oct 6, 2022
@rverchere
Copy link
Author

I confirm it works!

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # module.kubernetes-ovh-cluster.local_file.kubeconfig will be created
  + resource "local_file" "kubeconfig" {
      + content              = (sensitive)
      + directory_permission = "0755"
      + file_permission      = "0644"
      + filename             = "./../kubeconfig-<id>.yml"
      + id                   = (known after apply)
    }

@scraly
Copy link
Collaborator

scraly commented Oct 6, 2022

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants