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.5.1"
      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}/TerraformTestSolution_Complex_1_1_0_0.zip"
  settings_file  = local_file.solution_settings_file.filename
}

Schema

Required

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

Optional

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

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

Nested Schema for timeouts

Optional:

  • create (String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
  • delete (String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
  • read (String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Read operations occur during any refresh or planning operation when refresh is enabled.
  • update (String) A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).