powerplatform_solution (Resource)

Resource for importing exporting solutions in Power Platform environments. This is the equivalent of the pac solution import command in the Power Platform CLI.

Example Usage

terraform {
  required_providers {
    powerplatform = {
      source = "microsoft/power-platform"
    }
    local = {
      version = "2.4.0"
      source  = "hashicorp/local"
    }
  }
}

provider "powerplatform" {
  use_cli = true
}

provider "local" {}

resource "local_file" "solution_settings_file" {
  filename = "${path.module}/solution_settings.json"
  content  = <<EOF
{
  "EnvironmentVariables": [
    {
      "SchemaName": "cra6e_SolutionVariableDataSource",
      "Value": "/sites/Shared%20Documents1"
    },
    {
      "SchemaName": "cra6e_SolutionVariableJson",
      "Value": "{ \"value\": 1234, \"text\": \"abc\" }"
    },
    {
      "SchemaName": "cra6e_SolutionVariableText",
      "Value": "${powerplatform_environment.environment.id}"
    }
  ],
  "ConnectionReferences": [
    {
      "LogicalName": "cra6e_ConnectionReferenceSharePoint",
      "ConnectionId": "00000000-0000-0000-0000-000000000000",
      "ConnectorId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline"
    }
  ]
}
EOF
}

resource "powerplatform_environment" "environment" {
  display_name     = "Solution Import Test 1"
  location         = "europe"
  environment_type = "Sandbox"
  dataverse = {
    language_code     = "1033"
    currency_code     = "USD"
    security_group_id = "00000000-0000-0000-0000-000000000000"
  }
}

resource "powerplatform_solution" "solution" {
  environment_id = powerplatform_environment.environment.id
  solution_file  = "${path.module}/${var.solution_name}_Complex_1_1_0_0.zip"
  solution_name  = var.solution_name
  settings_file  = local_file.solution_settings_file.filename
  //settings_file  = "${path.module}/solution_settings_static.json"
}

Schema

Required

  • environment_id (String) Id of the environment where the solution is imported
  • solution_file (String) Path to the solution file
  • solution_name (String) Unique name of the solution

Optional

  • settings_file (String) Path to the settings file. The settings file uses the same format as pac cli. See https://learn.microsoft.com/en-us/power-platform/alm/conn-ref-env-variables-build-tools#deployment-settings-file for more details

Read-Only

  • display_name (String) Display name of the solution
  • id (String) Unique identifier of the solution
  • is_managed (Boolean) Indicates whether the solution is managed or not
  • settings_file_checksum (String) Checksum of the settings file
  • solution_file_checksum (String) Checksum of the solution file
  • solution_version (String) Version of the solution