IBM-Cloud / configuration-discovery

Infrastructure reverse engineering tool for IBM Cloud - Beta Release
Apache License 2.0
3 stars 8 forks source link

discovery tool - issue to import classic infrastructure resources #10

Open venkatmarella opened 1 year ago

venkatmarella commented 1 year ago

Describe the bug

We are attempting to retrieve one of our IBM container cluster services and we were pointed to this tool. During the discovery import attempt we encountered with Error: missing required argument where the missing arguments are datacenter and hardware.

To Reproduce Steps to reproduce the behavior:

  1. discovery import -r ibm_container_cluster --tags 'region:us-south'

Expected behavior I expect that the discovery tool would provide a list of the IBM container clusters that I can import to my existing terraform configuration.

Screenshots

While looking at the source, I believe the issue **Additional context** We have multiple clusters and would like to import one of the clusters that we are missing in our terraform configuration. Is there an option to do this through a filter or argument? Additionally, I believe this is the place that collects the cluster attributes. * https://github.com/GoogleCloudPlatform/terraformer/blob/135c42aa30a4ec940b988d0f5b62493fe38834fe/providers/ibm/container_cluster.go#L32-L51 * https://github.com/GoogleCloudPlatform/terraformer/blob/97c18b155c42a4b47b35e7deaeca4c385ba8cbff/terraformutils/resource.go#L92-L111 image (1)
anilkumarnagaraj commented 1 year ago

@venkatmarella

I am not able to reproduce the issue. Configuration Discovery tool was able to reverse engineer the container cluster resource with hardware & datacenter arguments.

resource "ibm_container_cluster" "tfer--container_cluster_poc" {
  datacenter                 = "dal10"
  default_pool_size          = "1"
  disk_encryption            = "true"
  force_delete_storage       = "true"
  hardware                   = "shared"
  image_security_enforcement = "false"
  kube_version               = "1.23.13"
  machine_type               = "b3c.4x16"
  name                       = "container-cluster-poc"
  pod_subnet                 = "172.30.0.0/16"
  private_service_endpoint   = "false"
  private_vlan_id            = "3266033"
  public_service_endpoint    = "true"
  public_vlan_id             = "3266031"
  resource_group_id          = "e7bd0d0e05f94c938c578b898751a0b3"
  service_subnet             = "172.21.0.0/16"
  tags                       = ["dnd", "schematicsid:us-south.workspace.iks_-_cluster_integrations.27f5ef18", "tf-int"]
  update_all_workers         = "false"
  wait_for_worker_update     = "true"

  workers_info {
    id      = "kube-ccgm7cdd0qkvl3dr0jtg-containercl-default-000001e8"
    version = "1.23.10"
  }

  workers_info {
    id      = "kube-ccgm7cdd0qkvl3dr0jtg-containercl-default-0000025a"
    version = "1.23.10"
  }

  workers_info {
    id      = "kube-ccgm7cdd0qkvl3dr0jtg-containercl-default-00000325"
    version = "1.23.10"
  }
}

Could you please follow the below steps and let us know if the issue still persists?

DrkCloudStrife commented 1 year ago

Hello @anilkumarnagaraj, this is Eddie. I'm working with @venkatmarella on this. Here are the results when running terraformer version:

➜ personal/ibm-discovery
 % terraformer version
Terraformer v0.8.22

Terraform plugins:

➜ personal/ibm-discovery
 % ls ~/.terraform.d/plugins/darwin_arm64
terraform-provider-helm terraform-provider-ibm

Discovery import command:


➜ personal/ibm-discovery
 % discovery import --services ibm_container_cluster --tags 'region:us-south' --config_name ibm_config
...
2022/11/01 15:02:01 terraform | │ Error: Missing required argument
2022/11/01 15:02:01 terraform | │
2022/11/01 15:02:01 terraform | │   on container_cluster.tf line 228, in resource "ibm_container_cluster" "tfer--management_cluster":
2022/11/01 15:02:01 terraform | │  228: resource "ibm_container_cluster" "tfer--management_cluster" {
2022/11/01 15:02:01 terraform | │
2022/11/01 15:02:01 terraform | │ The argument "hardware" is required, but no definition was found.
2022/11/01 15:02:01 terraform | ╵
2022/11/01 15:02:01 terraform | ╷
2022/11/01 15:02:01 terraform | │ Error: Missing required argument
2022/11/01 15:02:01 terraform | │
2022/11/01 15:02:01 terraform | │   on container_cluster.tf line 228, in resource "ibm_container_cluster" "tfer--management_cluster":
2022/11/01 15:02:01 terraform | │  228: resource "ibm_container_cluster" "tfer--management_cluster" {
2022/11/01 15:02:01 terraform | │
2022/11/01 15:02:01 terraform | │ The argument "datacenter" is required, but no definition was found.
2022/11/01 15:02:01 terraform | ╵
FAILED
Error in Importing resources: exit status 1

exit status 1

Additional Info:

➜ personal/ibm-discovery
 % ~/.terraform.d/plugins/darwin_arm64/terraform-provider-ibm --help
2022/11/01 15:05:13 IBM Cloud Provider version 1.45.1
This binary is a plugin. These are not meant to be executed directly.
Please execute the program that consumes these plugins, which will
load any plugins automatically
➜ personal/ibm-discovery
 % terraform -v
Terraform v1.0.3
on darwin_arm64

Your version of Terraform is out of date! The latest version
is 1.3.3. You can update by downloading from https://www.terraform.io/downloads.html
anilkumarnagaraj commented 1 year ago

@DrkCloudStrife

Thanks for the update.

Terraformer & provider version looks good to me.

Question: Cluster which you are trying to reverse engineer is it a free or paid one? If it's a free cluster, Terraform provider doesn't set datacenter and hardware parameter in ibm_container_cluster resource'.

DrkCloudStrife commented 1 year ago

@anilkumarnagaraj The clusters that we are retrieving from are paid. We originally opened a ticket with IBM Support and they directed us to this tool.

anilkumarnagaraj commented 1 year ago

@DrkCloudStrife

We will fix the issue in Terraformer code by setting datacenter and hardware parameters explicitly in ibm_container_cluster, will update you by tomorrow.

venkatmarella commented 1 year ago

@anilkumarnagaraj , any update on this?

anilkumarnagaraj commented 1 year ago

@venkatmarella @DrkCloudStrife

Please check the below slack channel link for a fix: https://ibm-cloud-schematics.slack.com/archives/C4R15M6SZ/p1667537273181949?thread_ts=1667228816.593309&cid=C4R15M6SZ

If the error still persists, share Terraformer generated files for our debugging.