microsoft / terraform-provider-power-platform

Power Platform Terraform Provider
https://registry.terraform.io/providers/microsoft/power-platform/latest/docs
MIT License
35 stars 13 forks source link

Add the ability powerplatform_environment_application_package_install (resource) to install, upgrade and delete of solutions from url/appsource #429

Closed webstean closed 1 month ago

webstean commented 2 months ago

Description

Allow solution installation from Microsoft ApppSource and ideally from any URL for the maximum flexibility.

Resource

Potential Terraform Configuration

resource "powerplatform_solution" "example" {
  environment_id = powerplatform_environment.example.id
  solution_file  = "${path.module}/${var.solution_name}_Complex_1_1_0_0.zip"
or
  solution_appsource = "Creator Kit"
  solution_appsource_publisher = "Microsoft Corp - Power CAT"
or
  solution_url = "https://cnn.com/solution.zip"

  settings_file  = local_file.solution_settings_file.filename
}

Definition of Done

Contributions

Do you plan to raise a PR to address this issue? NO

See the contributing guide for more information about what's expected for contributions.

mattdot commented 2 months ago

For solution_url, unless the API explicitly supports loading a solution from url, I think the "terraform" way to do this would be to use a local provisioner to download the file and then just use solution_file

resource "null_resource" "solution_zip" {

  provisioner "local-exec" {
    command = "curl -o solution.zip https://example.com/solution.zip"
  }

  provisioner "local-exec" {
    when    = destroy
    command = "rm solution.zip"
  }
}

will get back to you on app source

mattdot commented 2 months ago

Looks like appsource uses a different API https://api.admin.powerplatform.microsoft.com/api/AppManagement/AddTenantAppSourceRequest?geoType=Na. We will discuss.

mawasile commented 2 months ago

We do support appsource as a separate resource: https://github.com/microsoft/terraform-provider-power-platform/blob/main/examples/resources/powerplatform_environment_application_packages/resource.tf

webstean commented 2 months ago

This resource's documentation does not include any mention of appsource and talks about the "Dynamics 365 applications" which is very legacy commentary. So that probably needs to be modernised / updated.

powerplatform_environment_application_package_install (Resource) includes the statement: -

This resource does not support updating or deleting applications. The expected behavior is that the application is installed and remains installed until the environment is deleted.

So that is extremely limiting, and I don't see how the provider can go to GA, with these sort of limitations, it should support both deleting / upgrading existing solutions/applications.

webstean commented 2 months ago

Changed this issue, to be about improving: _powerplatform_environment_application_packageinstal (resource)

mattdot commented 2 months ago

Yeah, that resource is not for AppSource. We don't have a way to install from appsource right now.

That resource covers what the current documentation and admin center UI calls Dynamics 365 apps

https://learn.microsoft.com/en-us/power-platform/admin/manage-apps

The terminology Power Platform itself uses is very confusing in this space since you have solutions, app packages, d365 tenant apps, d365 environment apps, app source, etc. As much as possible we want to be consistent with how admin center or the underlying API refers to features to avoid confusion. But there's clearly some confusion here. I like how you're thinking about the space. I don't know if/how we can unify all these concepts into one resource. Willing to keep exploring though.

webstean commented 2 months ago

Thanks for the clarification and guidance, I've updated my issues appropriately.

webstean commented 2 months ago

For solution_url, unless the API explicitly supports loading a solution from url, I think the "terraform" way to do this would be to use a local provisioner to download the file and then just use solution_file

resource "null_resource" "solution_zip" {

  provisioner "local-exec" {
    command = "curl -o solution.zip https://example.com/solution.zip"
  }

  provisioner "local-exec" {
    when    = destroy
    command = "rm solution.zip"
  }
}

@mattdot Yes, you could do that, but the goal of a provider should be hide the details of the underlying API from the terraform developer. I would imagine it would be a requirement to install a solution ZIP file from a Storage Blob (which could just be a URL) and the provider should support that directly, regardless of if the underlying API supports it or not. IMHO.

mattdot commented 1 month ago

We did some research on this. App Source, Catalog, and D365 apps are all installed as "application packages" which may not be a single solution. Could be 0 to many. Therefore, it doesn't make sense to combine these with the solution resource. Because they are all slightly different they will be in separate resource types. We will add a resource to the backlog for appsource. Let us know if you need Catalog.

mattdot commented 1 month ago

We did some research on this. App Source, Catalog, and D365 apps are all installed as "application packages" which may not be a single solution. Could be 0 to many. Therefore it doesn't make sense to combine these with the solution resource.