deploymenttheory / terraform-provider-jamfpro

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

Issue: jamfpro_package broken #323

Closed kenchan0130 closed 2 months ago

kenchan0130 commented 3 months ago

Terraform (and Provider) Version

Terraform v1.8.5 on darwin_amd64

provider deploymenttheory/terraform-provider-jamfpro v0.1.5

Affected Resource(s)

Terraform Configuration Files

resource "jamfpro_package" "sample" {
  package_name          = "tf-example-package-your-package-name"
  package_file_source   = "sample.pkg"
  priority              = 10
  reboot_required       = true
  fill_user_template    = false
  fill_existing_users   = false
  os_install            = false
  suppress_updates      = false
  suppress_from_dock    = false
  suppress_eula         = false
  suppress_registration = false
}

Expected Behavior

Expect files tied to package file to be uploaded.

Actual Behavior

The file cannot be uploaded and an error is obtained.

│ Error: failed to upload package file for package '39': failed to upload package: {"status_code":500,"method":"POST","url":"https://xxxxx.jamfcloud.com/api/v1/packages/39/upload","message":"API Error Response","raw_response":""}
│
│   with jamfpro_package.sample,
│   on main.tf line 1, in resource "jamfpro_package" "sample":
│    1: resource "jamfpro_package" "sample" {

Steps to Reproduce

  1. Execute terraform apply
  2. Execute terraform apply again

Important Factoids

After the first executing terraform apply, I confirmed the corresponding package from the jamf pro website and found the following error message indicating that the file had not been uploaded.

screenshot
ShocOne commented 3 months ago

Hi, can you confirm the file source please. Is it local, http or https ? Second, the 500 error is typically when the provider is trying to create the package metadata and it already exists within jamfpro.

ShocOne commented 2 months ago

As a follow up, reviewing your code example and your PR, i believe lies with the fact you are missing the category id in your hcl. Will close the ticket. Thanks

kenchan0130 commented 2 months ago

@ShocOne

can you confirm the file source please. Is it local, http or https ?

It is a local file.

スクリーンショット 2024-07-12 9 26 41

Second, the 500 error is typically when the provider is trying to create the package metadata and it already exists within jamfpro.

I see that it is not a terraform provider issue as I am getting the same error on the Jamf pro UI.


As a follow up, reviewing your code example and your PR, i believe lies with the fact you are missing the category id in your hcl. Will close the ticket. Thanks

According to this provider's source code, the category_id is optional and default value is -1. From this, I recognize that the category_id is not relevant to this issue.

ShocOne commented 2 months ago

Here are some working examples from my demo repo

// Example of referencing a package directly within the repository
resource "jamfpro_package" "jamfpro_package_001" {
  package_name          = "tf-ghatest-package-suspiciouspackage"
  package_file_source   = "support_files/packages/gha-test-SuspiciousPackage.dmg"
  category_id           = "-1" // jamfpro_category.jamfpro_category_001.id
  info                  = "tf package deployment for demonstration"
  notes                 = "Uploaded by: terraform-provider-jamfpro plugin."
  priority              = 10
  reboot_required       = true
  fill_user_template    = false
  fill_existing_users   = false
  os_requirements       = "macOS 10.15.0"
  swu                   = false
  self_heal_notify      = false
  os_install            = false
  serial_number         = ""
  suppress_updates      = false
  ignore_conflicts      = false
  suppress_from_dock    = false
  suppress_eula         = false
  suppress_registration = false
  manifest              = ""
  manifest_file_name    = ""
}

// https://go.microsoft.com/fwlink/?linkid=853070 - company portal
// https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US - firefox

// Example of referencing a package from a https source (with redirects)
resource "jamfpro_package" "jamfpro_package_02" {
  package_name          = "tf-ghatest-package-httpsourceprovider-test"
  package_file_source   = "https://download.mozilla.org/?product=firefox-latest&os=osx&lang=en-US"
  category_id           = "-1"
  info                  = "tf package deployment for demonstration"
  notes                 = "Uploaded by: terraform-provider-jamfpro plugin."
  priority              = 10
  reboot_required       = true
  fill_user_template    = false
  fill_existing_users   = false
  os_requirements       = "macOS 10.15.0"
  swu                   = false
  self_heal_notify      = false
  os_install            = false
  serial_number         = ""
  suppress_updates      = false
  ignore_conflicts      = false
  suppress_from_dock    = false
  suppress_eula         = false
  suppress_registration = false
  manifest              = ""
  manifest_file_name    = ""
}

// Example of referencing a package from a https source
resource "jamfpro_package" "jamfpro_package_03" {
  package_name          = "tf-ghatest-package-httpsourceprovider-companyportal"
  package_file_source   = "https://go.microsoft.com/fwlink/?linkid=853070"
  category_id           = "-1"
  info                  = "tf package deployment for demonstration"
  notes                 = "Uploaded by: terraform-provider-jamfpro plugin."
  priority              = 10
  reboot_required       = true
  fill_user_template    = false
  fill_existing_users   = false
  os_requirements       = "macOS 10.15.0"
  swu                   = false
  self_heal_notify      = false
  os_install            = false
  serial_number         = ""
  suppress_updates      = false
  ignore_conflicts      = false
  suppress_from_dock    = false
  suppress_eula         = false
  suppress_registration = false
  manifest              = ""
  manifest_file_name    = ""
}

for awareness - https://github.com/deploymenttheory/terraform-demo-jamfpro

kenchan0130 commented 2 months ago

As mentioned, this is likely a problem specific to my jamf pro instance, so this issue is in the correct state of closed.

Thank you for your support.

ShocOne commented 2 months ago

Happy to help