site24x7 / terraform-provider-site24x7

Terraform provider for Site24x7
MIT License
22 stars 33 forks source link

Can't Import Most Resources (Makes Adoption Painful) #253

Closed jamiejackson closed 3 months ago

jamiejackson commented 4 months ago

I was pleased to see that site24x7 has a provider so I started trying it over the last two days.

I'm used to providers that have full-featured terraform import ability, which makes them easy to adopt, even if the project has already gotten started by manually provisioning resources.

Unfortunately, I'm finding that a lot (most?) resource types aren't importable with the site24x7 provider. That makes it 10x harder to terraform an existing setup. There are so many hoops to jump through when you have to create parallel resources from scratch.

Am I wrong that the provider is missing a lot of import functionality? I'm hoping that I'm misunderstanding all of these resource site24x7_xxx doesn't support import.

So far, I've only tried a handful of resource types, but I've only found one (site24x7_website_monitor) to be importable. Here are the other ones I've tried, none of which are importable:

If I'm not wrong, what's the roadmap for properly supporting imports?

Terraforming our site24x7 setup might not be worth how painful it would be to do so in the provider's current state.

jim-billy-zoho commented 3 months ago

@jamiejackson Thank you for raising this issue. Please use the latest version 1.0.83 and let us know whether your imports are successful.

jamiejackson commented 3 months ago

This is great, thanks!

Update: I've spun off the following problem to #263

However, I am seeing odd behavior. Here's one example. (I'll add others later.)

I have version 1.0.84.

I imported this user:

locals {
  notification_medium = {
    email = 1
    sms   = 2
    voice = 3
  }
  notification_medium_all = [1,2,3]
}

resource "site24x7_user" "user_a" {
  display_name  = "REDACTED"
  email_address = "REDACTED"
  statusiq_role = 22
  user_role     = 2
  notification_medium = local.notification_medium_all
  up_notification_medium = local.notification_medium_all
  down_notification_medium = local.notification_medium_all
  trouble_notification_medium = local.notification_medium_all
  critical_notification_medium = local.notification_medium_all
  mobile_settings = {
    "country_code" = "1"
    "mobile_number" = "5555555555"
  }
}

Before I had mobile_settings.mobile_number defined, I would intermittently get plans that said it would remove it.

Because I was getting this dodgy behavior, I explicitly added it. Now, I intermittently get the following when I do a plan:

  # site24x7_user.ajay will be updated in-place
  ~ resource "site24x7_user" "user_a" {
        id                           = "207348000012304001"
      ~ mobile_settings              = {
          + "mobile_number" = "5555555555"
            # (1 unchanged element hidden)
        }
        # (18 unchanged attributes hidden)
    }

It doesn't matter how many times I terraform apply.

jamiejackson commented 3 months ago

Update: This is independent of import. I created a monitor from scratch and it has the same issue. New ticket: #261 .

I don' t know whether these are independent of the new import functionality or not, so I may have to file separate tickets for some of this stuff, but here's another example.

I have a similar problem with this resource. This one's constant, though.

locals {
  credential_type = {
    vmware_vcenter           = 1
    vmware_esx               = 2
    web_credentials          = 3
    vmware_vdi               = 4
    client_certificates      = 5
    ssh                      = 7
    nutanix_cluster          = 6
    lama_credentials         = 9
    veeam_enterprise_manager = 8
  }
  # the oauth access token doesn't seem to have permissions to do a credentials lookup
  credentials = {
    stage_basic_auth_id = "207348000012018001"
  }
  auth_method = {
    basic    = "B"
    oauth2   = "O"
    webtoken = "W"
  }
}

resource "site24x7_website_monitor" "home_page__stage" {
  display_name                = "Home Page"
  website                     = "https://example.com/"
  auth_method                 = local.auth_method.basic
  check_frequency             = "1"
  credential_profile_id       = local.credentials.stage_basic_auth_id
  ignore_cert_err             = false
  location_profile_id         = site24x7_location_profile.united_states.id
  match_regex_severity        = 2
  matching_keyword_severity   = 0
  matching_keyword_value      = "need housing assistance"
  timeout                     = 30
  unmatching_keyword_severity = 2
  use_name_server             = false
  monitor_groups = [
    site24x7_monitor_group.stage.id
  ]
  third_party_service_ids = ["207348000005128003"]
}

terraform plan always shows.

  # site24x7_website_monitor.home_page__stage will be updated in-place
  ~ resource "site24x7_website_monitor" "home_page__stage" {
      - auth_user                   = "REDACTED" -> null
        id                          = "207348000000114064"
        # (41 unchanged attributes hidden)
    }