Skip to content

Commit 9b6f811

Browse files
committed
Add Dataverse git integration resources
1 parent b181fe8 commit 9b6f811

24 files changed

Lines changed: 3117 additions & 0 deletions
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "powerplatform_environment_git_integration Resource - Power Platform"
4+
subcategory: ""
5+
description: |-
6+
Manages the environment-level Dataverse Git repository binding. This maps to the documented sourcecontrolconfiguration Dataverse table and stores the repository connection metadata for an environment.
7+
---
8+
9+
# powerplatform_environment_git_integration (Resource)
10+
11+
Manages the environment-level Dataverse Git repository binding. This maps to the documented `sourcecontrolconfiguration` Dataverse table and stores the repository connection metadata for an environment.
12+
13+
## Example Usage
14+
15+
```terraform
16+
terraform {
17+
required_providers {
18+
powerplatform = {
19+
source = "microsoft/power-platform"
20+
}
21+
}
22+
}
23+
24+
provider "powerplatform" {
25+
use_cli = true
26+
}
27+
28+
# Use `scope = "Environment"` to mirror the maker UI environment-level binding.
29+
# In this mode the provider manages the root Dataverse binding and proactively
30+
# enables eligible visible unmanaged solutions in the environment. Built-in
31+
# platform solutions are excluded automatically.
32+
resource "powerplatform_environment" "example" {
33+
display_name = var.environment_display_name
34+
description = "Example environment for validating Dataverse Git integration."
35+
location = var.location
36+
azure_region = var.azure_region
37+
environment_type = "Sandbox"
38+
dataverse = {
39+
language_code = "1033"
40+
currency_code = "USD"
41+
security_group_id = var.security_group_id
42+
}
43+
}
44+
45+
resource "powerplatform_environment_git_integration" "example" {
46+
environment_id = powerplatform_environment.example.id
47+
git_provider = var.git_provider
48+
scope = var.scope
49+
organization_name = var.organization_name
50+
project_name = var.project_name
51+
repository_name = var.repository_name
52+
}
53+
```
54+
55+
<!-- schema generated by tfplugindocs -->
56+
## Schema
57+
58+
### Required
59+
60+
- `environment_id` (String) Environment ID of the Dataverse environment where the Git repository binding will be created.
61+
- `git_provider` (String) Git provider for the repository binding. Supported value is `AzureDevOps`.
62+
- `organization_name` (String) Organization or owner name for the configured Git provider.
63+
- `project_name` (String) Project name for the Azure DevOps repository binding.
64+
- `repository_name` (String) Repository name that the environment will bind to.
65+
- `scope` (String) Source control integration scope for the environment. Use `Solution` for solution-level branch bindings and `Environment` for an environment-level binding. In `Environment` scope, the provider manages the root branch binding and proactively enables eligible visible unmanaged solutions in the environment while excluding platform-owned default solutions.
66+
67+
### Optional
68+
69+
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))
70+
71+
### Read-Only
72+
73+
- `id` (String) Unique identifier of the Dataverse source control configuration.
74+
75+
<a id="nestedatt--timeouts"></a>
76+
### Nested Schema for `timeouts`
77+
78+
Optional:
79+
80+
- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
81+
- `delete` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) 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.
82+
- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) 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.
83+
- `update` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
84+
85+
## Import
86+
87+
Import is supported using the following syntax:
88+
89+
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
90+
91+
```shell
92+
# Environment Git integration resources can be imported using the environment id (replace with a real environment id)
93+
terraform import powerplatform_environment_git_integration.example 00000000-0000-0000-0000-000000000000
94+
```
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "powerplatform_solution_git_branch Resource - Power Platform"
4+
subcategory: ""
5+
description: |-
6+
Manages a solution-level Dataverse Git branch binding. This maps to the documented sourcecontrolbranchconfiguration Dataverse table and links a solution partition to a branch and folder beneath an environment Git integration.
7+
---
8+
9+
# powerplatform_solution_git_branch (Resource)
10+
11+
Manages a solution-level Dataverse Git branch binding. This maps to the documented `sourcecontrolbranchconfiguration` Dataverse table and links a solution partition to a branch and folder beneath an environment Git integration.
12+
13+
## Example Usage
14+
15+
```terraform
16+
terraform {
17+
required_providers {
18+
local = {
19+
source = "hashicorp/local"
20+
version = "2.6.2"
21+
}
22+
powerplatform = {
23+
source = "microsoft/power-platform"
24+
}
25+
}
26+
}
27+
28+
provider "local" {}
29+
30+
provider "powerplatform" {
31+
use_cli = true
32+
}
33+
34+
resource "local_file" "solution_settings_file" {
35+
filename = "${path.module}/solution_settings.json"
36+
content = <<EOF
37+
{
38+
"EnvironmentVariables": [
39+
{
40+
"SchemaName": "cra6e_SolutionVariableDataSource",
41+
"Value": "/sites/Shared Documents"
42+
},
43+
{
44+
"SchemaName": "cra6e_SolutionVariableJson",
45+
"Value": "{ \"value\": 1234, \"text\": \"abc\" }"
46+
},
47+
{
48+
"SchemaName": "cra6e_SolutionVariableText",
49+
"Value": "${powerplatform_environment.example.id}"
50+
}
51+
],
52+
"ConnectionReferences": [
53+
{
54+
"LogicalName": "cra6e_ConnectionReferenceSharePoint",
55+
"ConnectionId": "00000000-0000-0000-0000-000000000000",
56+
"ConnectorId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline"
57+
}
58+
]
59+
}
60+
EOF
61+
}
62+
63+
resource "powerplatform_environment" "example" {
64+
display_name = var.environment_display_name
65+
description = "Example environment for validating Dataverse Git branch bindings."
66+
location = var.location
67+
azure_region = var.azure_region
68+
environment_type = "Sandbox"
69+
dataverse = {
70+
language_code = "1033"
71+
currency_code = "USD"
72+
security_group_id = var.security_group_id
73+
}
74+
}
75+
76+
resource "powerplatform_solution" "example" {
77+
environment_id = powerplatform_environment.example.id
78+
solution_file = coalesce(var.solution_file, "${path.module}/../powerplatform_solution/TerraformTestSolution_Complex_1_1_0_0.zip")
79+
settings_file = local_file.solution_settings_file.filename
80+
}
81+
82+
resource "powerplatform_environment_git_integration" "example" {
83+
count = var.enable_git_binding ? 1 : 0
84+
85+
environment_id = powerplatform_environment.example.id
86+
git_provider = var.git_provider
87+
scope = var.scope
88+
organization_name = var.organization_name
89+
project_name = var.project_name
90+
repository_name = var.repository_name
91+
}
92+
93+
resource "powerplatform_solution_git_branch" "example" {
94+
count = var.enable_git_binding ? 1 : 0
95+
96+
environment_id = powerplatform_environment.example.id
97+
git_integration_id = powerplatform_environment_git_integration.example[0].id
98+
solution_id = powerplatform_solution.example.id
99+
branch_name = var.branch_name
100+
upstream_branch_name = var.upstream_branch_name
101+
root_folder_path = var.root_folder_path
102+
}
103+
```
104+
105+
<!-- schema generated by tfplugindocs -->
106+
## Schema
107+
108+
### Required
109+
110+
- `branch_name` (String) Branch name to bind the solution partition to.
111+
- `environment_id` (String) Environment ID of the Dataverse environment where the branch binding exists.
112+
- `git_integration_id` (String) ID of the parent `powerplatform_environment_git_integration` resource.
113+
- `root_folder_path` (String) Repository folder path that stores the solution's files.
114+
- `solution_id` (String) ID of the existing `powerplatform_solution` resource to bind to the Git branch. This must use the provider solution ID format for the same environment.
115+
116+
### Optional
117+
118+
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))
119+
- `upstream_branch_name` (String) Upstream branch name. When omitted, the provider will use the same value as `branch_name`.
120+
121+
### Read-Only
122+
123+
- `id` (String) Unique identifier of the Dataverse source control branch configuration.
124+
125+
<a id="nestedatt--timeouts"></a>
126+
### Nested Schema for `timeouts`
127+
128+
Optional:
129+
130+
- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
131+
- `delete` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) 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.
132+
- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) 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.
133+
- `update` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
134+
135+
## Import
136+
137+
Import is supported using the following syntax:
138+
139+
The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:
140+
141+
```shell
142+
# Solution Git branch resources can be imported using environment_id/git_integration_id/solution_id
143+
# The final segment can be either the raw Dataverse solution id or the provider-formatted powerplatform_solution.id
144+
terraform import powerplatform_solution_git_branch.example 00000000-0000-0000-0000-000000000000/11111111-1111-1111-1111-111111111111/00000000-0000-0000-0000-000000000000_22222222-2222-2222-2222-222222222222
145+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Environment Git integration resources can be imported using the environment id (replace with a real environment id)
2+
terraform import powerplatform_environment_git_integration.example 00000000-0000-0000-0000-000000000000
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
output "environment_id" {
2+
description = "Unique identifier of the example environment."
3+
value = powerplatform_environment.example.id
4+
}
5+
6+
output "git_integration_id" {
7+
description = "Unique identifier of the environment Git integration binding."
8+
value = powerplatform_environment_git_integration.example.id
9+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
terraform {
2+
required_providers {
3+
powerplatform = {
4+
source = "microsoft/power-platform"
5+
}
6+
}
7+
}
8+
9+
provider "powerplatform" {
10+
use_cli = true
11+
}
12+
13+
# Use `scope = "Environment"` to mirror the maker UI environment-level binding.
14+
# In this mode the provider manages the root Dataverse binding and proactively
15+
# enables eligible visible unmanaged solutions in the environment. Built-in
16+
# platform solutions are excluded automatically.
17+
resource "powerplatform_environment" "example" {
18+
display_name = var.environment_display_name
19+
description = "Example environment for validating Dataverse Git integration."
20+
location = var.location
21+
azure_region = var.azure_region
22+
environment_type = "Sandbox"
23+
dataverse = {
24+
language_code = "1033"
25+
currency_code = "USD"
26+
security_group_id = var.security_group_id
27+
}
28+
}
29+
30+
resource "powerplatform_environment_git_integration" "example" {
31+
environment_id = powerplatform_environment.example.id
32+
git_provider = var.git_provider
33+
scope = var.scope
34+
organization_name = var.organization_name
35+
project_name = var.project_name
36+
repository_name = var.repository_name
37+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
variable "environment_display_name" {
2+
default = "example-git-integration-environment"
3+
description = "Display name of the example environment."
4+
type = string
5+
}
6+
7+
variable "location" {
8+
default = "europe"
9+
description = "Power Platform geography for the example environment."
10+
type = string
11+
}
12+
13+
variable "azure_region" {
14+
default = "northeurope"
15+
description = "Azure region for the Dataverse-backed example environment."
16+
type = string
17+
}
18+
19+
variable "security_group_id" {
20+
default = "00000000-0000-0000-0000-000000000000"
21+
description = "Security group ID for Dataverse provisioning. Use the zero GUID to disable."
22+
type = string
23+
}
24+
25+
variable "git_provider" {
26+
default = "AzureDevOps"
27+
description = "Git provider to bind. Supported value is AzureDevOps."
28+
type = string
29+
}
30+
31+
variable "scope" {
32+
default = "Environment"
33+
description = "Source control integration scope. Use Environment for environment-scoped bindings or Solution when pairing with powerplatform_solution_git_branch."
34+
type = string
35+
}
36+
37+
variable "organization_name" {
38+
default = "example-org"
39+
description = "Git organization or owner name."
40+
type = string
41+
}
42+
43+
variable "project_name" {
44+
default = "example-project"
45+
description = "Git project name used for Azure DevOps bindings."
46+
type = string
47+
}
48+
49+
variable "repository_name" {
50+
default = "example-repo"
51+
description = "Git repository name to bind to the environment."
52+
type = string
53+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Solution Git branch resources can be imported using environment_id/git_integration_id/solution_id
2+
# The final segment can be either the raw Dataverse solution id or the provider-formatted powerplatform_solution.id
3+
terraform import powerplatform_solution_git_branch.example 00000000-0000-0000-0000-000000000000/11111111-1111-1111-1111-111111111111/00000000-0000-0000-0000-000000000000_22222222-2222-2222-2222-222222222222
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
output "environment_id" {
2+
description = "Unique identifier of the example environment."
3+
value = powerplatform_environment.example.id
4+
}
5+
6+
output "solution_id" {
7+
description = "Provider-formatted ID of the example unmanaged solution."
8+
value = powerplatform_solution.example.id
9+
}
10+
11+
output "git_integration_id" {
12+
description = "Unique identifier of the environment Git integration binding, if enabled."
13+
value = try(powerplatform_environment_git_integration.example[0].id, null)
14+
}
15+
16+
output "solution_git_branch_id" {
17+
description = "Unique identifier of the solution Git branch binding, if enabled."
18+
value = try(powerplatform_solution_git_branch.example[0].id, null)
19+
}

0 commit comments

Comments
 (0)