deploymenttheory / terraform-provider-jamfpro

Jamf Pro Terraform Provider/Plugin written with the TF Provider SDK v2. Written in go
Mozilla Public License 2.0
28 stars 10 forks source link

jamfpro_computer_prestage_enrollment resources broken #383

Closed mhrono closed 2 weeks ago

mhrono commented 2 weeks ago

I was starting the process of defining our existing prestages to prepare for importing them, and found that some fields marked optional in the documentation are causing plans to fail if not specified. This also includes some computed values in nested schemas. Details below:

ShocOne commented 2 weeks ago

Please could you share the HCL configuration you are trying to deploy, minus any org specific identifiers and I'll perform some tests with the sdk. Thanks

mhrono commented 2 weeks ago
resource "jamfpro_computer_prestage_enrollment" "classic-default" {
    ## required
    auto_advance_setup = false
    default_prestage = true
    device_enrollment_program_instance_id = 1
    display_name = ""
    enable_device_based_activation_lock = false
    install_profiles_during_setup = true
    keep_existing_location_information = false
    keep_existing_site_membership = false
    mandatory = true
    mdm_removable = false
    prevent_activation_lock = true
    require_authentication = false
    ## optional
    account_settings {
      payload_configured = true
      local_admin_account_enabled = true
      admin_username = ""
      admin_password = ""
      hidden_admin_account = true
      local_user_managed = false
      user_account_type = "ADMINISTRATOR"
      prefill_primary_account_info_feature_enabled = false
      prefill_type = "DEVICE_OWNER"
      prevent_prefill_info_from_modification = false
    }
    authentication_prompt = ""
    custom_package_distribution_point_id = -1
    department = "IT Support"
    enable_recovery_lock = false
    enrollment_customization_id = 0
    prestage_installed_profile_ids = [
        17
    ]
    rotate_recovery_lock_password = false
    site_id = -1
    skip_setup_items {
      biometric = true
      terms_of_address = true
      file_vault = false
      icloud_diagnostics = true
      diagnostics = true
      accessibility = false
      apple_id = true
      screen_time = true
      siri = true
      display_tone = false
      restore = true
      appearance = true
      privacy = true
      payment = true
      registration = true
      tos = true
      icloud_storage = true
      location = true
    }
}

plan output:

 Error: Missing required argument
│ 
│   on prestage-enrollments.tf line 1, in resource "jamfpro_computer_prestage_enrollment" "classic-default":
│    1: resource "jamfpro_computer_prestage_enrollment" "classic-default" {
│ 
│ The argument "support_phone_number" is required, but no definition was
│ found.
╵
╷
│ Error: Missing required argument
│ 
│   on prestage-enrollments.tf line 1, in resource "jamfpro_computer_prestage_enrollment" "classic-default":
│    1: resource "jamfpro_computer_prestage_enrollment" "classic-default" {
│ 
│ The argument "enrollment_site_id" is required, but no definition was found.
╵
╷
│ Error: Insufficient purchasing_information blocks
│ 
│   on prestage-enrollments.tf line 1, in resource "jamfpro_computer_prestage_enrollment" "classic-default":
│    1: resource "jamfpro_computer_prestage_enrollment" "classic-default" {
│ 
│ At least 1 "purchasing_information" blocks are required.
╵
╷
│ Error: Insufficient location_information blocks
│ 
│   on prestage-enrollments.tf line 1, in resource "jamfpro_computer_prestage_enrollment" "classic-default":
│    1: resource "jamfpro_computer_prestage_enrollment" "classic-default" {
│ 
│ At least 1 "location_information" blocks are required.
mhrono commented 2 weeks ago

Additionally, when I add a location_information block, you'll notice the only 2 keys it doesn't complain about are the 2 specified, and computed keys like id are marked as missing.

location_information {
      department_id = -1
      building_id = -1
}
 Error: Missing required argument
│ 
│   on prestage-enrollments.tf line 31, in resource "jamfpro_computer_prestage_enrollment" "classic-default":
│   31:     location_information {
│ 
│ The argument "phone" is required, but no definition was found.
╵
╷
│ Error: Missing required argument
│ 
│   on prestage-enrollments.tf line 31, in resource "jamfpro_computer_prestage_enrollment" "classic-default":
│   31:     location_information {
│ 
│ The argument "username" is required, but no definition was found.
╵
╷
│ Error: Missing required argument
│ 
│   on prestage-enrollments.tf line 31, in resource "jamfpro_computer_prestage_enrollment" "classic-default":
│   31:     location_information {
│ 
│ The argument "id" is required, but no definition was found.
╵
╷
│ Error: Missing required argument
│ 
│   on prestage-enrollments.tf line 31, in resource "jamfpro_computer_prestage_enrollment" "classic-default":
│   31:     location_information {
│ 
│ The argument "room" is required, but no definition was found.
╵
╷
│ Error: Missing required argument
│ 
│   on prestage-enrollments.tf line 31, in resource "jamfpro_computer_prestage_enrollment" "classic-default":
│   31:     location_information {
│ 
│ The argument "position" is required, but no definition was found.
╵
╷
│ Error: Missing required argument
│ 
│   on prestage-enrollments.tf line 31, in resource "jamfpro_computer_prestage_enrollment" "classic-default":
│   31:     location_information {
│ 
│ The argument "email" is required, but no definition was found.
╵
╷
│ Error: Missing required argument
│ 
│   on prestage-enrollments.tf line 31, in resource "jamfpro_computer_prestage_enrollment" "classic-default":
│   31:     location_information {
│ 
│ The argument "version_lock" is required, but no definition was found.
╵
╷
│ Error: Missing required argument
│ 
│   on prestage-enrollments.tf line 31, in resource "jamfpro_computer_prestage_enrollment" "classic-default":
│   31:     location_information {
│ 
│ The argument "realname" is required, but no definition was found.
╵
ShocOne commented 2 weeks ago

Your HCL, is missing a lot of required config fields. Hence your errors messages. This resource requires multiple fields to be present in all scenarios regardless of whether you set a real value in then or not.

Please see the example for minimum viable config and more: https://github.com/deploymenttheory/terraform-provider-jamfpro/blob/main/examples/resources/jamfpro_computer_prestage_enrollments/resource.tf

ShocOne commented 2 weeks ago

i've also implemented PR #384 to make things more explicit.

mhrono commented 2 weeks ago

This issue should be reopened. I copied your minimum viable config exactly from the link provided, and this is the plan output:

│ Error: Missing required argument
│ 
│   on prestage-enrollments.tf line 190, in resource "jamfpro_computer_prestage_enrollment" "example":
│  190:   location_information {
│ 
│ The argument "id" is required, but no definition was found.
╵
╷
│ Error: Missing required argument
│ 
│   on prestage-enrollments.tf line 190, in resource "jamfpro_computer_prestage_enrollment" "example":
│  190:   location_information {
│ 
│ The argument "version_lock" is required, but no definition was found.
╵
╷
│ Error: Missing required argument
│ 
│   on prestage-enrollments.tf line 200, in resource "jamfpro_computer_prestage_enrollment" "example":
│  200:   purchasing_information {
│ 
│ The argument "version_lock" is required, but no definition was found.
╵
╷
│ Error: Missing required argument
│ 
│   on prestage-enrollments.tf line 200, in resource "jamfpro_computer_prestage_enrollment" "example":
│  200:   purchasing_information {
│ 
│ The argument "id" is required, but no definition was found.

Computed fields are still causing the plan to fail as they're marked required. This resource is non-functional in its current state.