-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improving documentation of importing resources (#403)
- Loading branch information
Showing
13 changed files
with
162 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,3 +82,5 @@ makefile | |
|
||
# MSI files | ||
*.msi | ||
|
||
examples/temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
page_title: "Importing existing Power Platform resources" | ||
subcategory: "Guides" | ||
description: |- | ||
<no value> | ||
--- | ||
|
||
# Importing existing Power Platform resources | ||
|
||
Many of the resources in the Power Platform provider can be imported into your Terraform configuration. This guide will show you how to import existing resources into your configuration. Resources that can be imported have an `import` section in their documentation. | ||
|
||
## Using `terraform import` | ||
|
||
Using `terraform import` will only import resources into the state. It does not generate configuration and requires that you write the configuration yourself and ensure that it is correct. | ||
|
||
```bash | ||
terraform import powerplatform_environment.example_env 00000000-0000-0000-0000-000000000001 | ||
``` | ||
|
||
## Using import blocks | ||
|
||
Terraform allows the use of import blocks to import existing resources into your configuration. This can be useful if you have pre-existing resources that you want to manage with Terraform. The following is an example of an import block used to import the default Power Platform environment: | ||
|
||
```terraform | ||
import { | ||
to = powerplatform_environment.example_env | ||
id = "00000000-0000-0000-0000-000000000001" | ||
} | ||
resource "powerplatform_environment" "default" { | ||
display_name = "Contoso (default)" | ||
location = "unitedstates" | ||
environment_type = "Default" | ||
dataverse = { | ||
currency_code = "USD" | ||
language_code = 1033 | ||
security_group_id = "00000000-0000-0000-0000-000000000000" | ||
} | ||
lifecycle { | ||
prevent_destroy = true | ||
} | ||
} | ||
``` | ||
Terraform processes the import block during the plan stage. Once a plan is approved, Terraform imports the resource into its state during the subsequent apply stage. | ||
|
||
```bash | ||
terraform apply | ||
``` | ||
|
||
## Generating configuration | ||
|
||
Terraform has [experimental support for generating configuration from import blocks](https://developer.hashicorp.com/terraform/language/import/generating-configuration). This feature is not perfect, but it can help you get started with your configuration if you have some pre-existing resources. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Billing policies can be imported using the billing policy id (replace with a real billing policy guid) | ||
terraform import powerplatform_billing_policy.example 00000000-0000-0000-0000-000000000000 |
2 changes: 2 additions & 0 deletions
2
examples/resources/powerplatform_data_loss_prevention_policy/import.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# DLP Policies can be imported using the DLP policy id (replace with a real DLP Policy guid) | ||
terraform import powerplatform_data_loss_prevention_policy.example_dlp 00000000-0000-0000-0000-000000000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Environment resource can be imported using the environment id (replace with a real environment guid) | ||
terraform import powerplatform_environment.example 00000000-0000-0000-0000-000000000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Environment Groups can be imported using the environment group id (replace with a real environment group guid) | ||
terraform import powerplatform_environment_group.example 00000000-0000-0000-0000-000000000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
page_title: "Importing existing Power Platform resources" | ||
subcategory: "Guides" | ||
description: |- | ||
{{ .Description }} | ||
--- | ||
|
||
# Importing existing Power Platform resources | ||
|
||
Many of the resources in the Power Platform provider can be imported into your Terraform configuration. This guide will show you how to import existing resources into your configuration. Resources that can be imported have an `import` section in their documentation. | ||
|
||
## Using `terraform import` | ||
|
||
Using `terraform import` will only import resources into the state. It does not generate configuration and requires that you write the configuration yourself and ensure that it is correct. | ||
|
||
```bash | ||
terraform import powerplatform_environment.example_env 00000000-0000-0000-0000-000000000001 | ||
``` | ||
|
||
## Using import blocks | ||
|
||
Terraform allows the use of import blocks to import existing resources into your configuration. This can be useful if you have pre-existing resources that you want to manage with Terraform. The following is an example of an import block used to import the default Power Platform environment: | ||
|
||
```terraform | ||
import { | ||
to = powerplatform_environment.example_env | ||
id = "00000000-0000-0000-0000-000000000001" | ||
} | ||
|
||
resource "powerplatform_environment" "default" { | ||
display_name = "Contoso (default)" | ||
location = "unitedstates" | ||
environment_type = "Default" | ||
dataverse = { | ||
currency_code = "USD" | ||
language_code = 1033 | ||
security_group_id = "00000000-0000-0000-0000-000000000000" | ||
} | ||
|
||
lifecycle { | ||
prevent_destroy = true | ||
} | ||
} | ||
``` | ||
Terraform processes the import block during the plan stage. Once a plan is approved, Terraform imports the resource into its state during the subsequent apply stage. | ||
|
||
```bash | ||
terraform apply | ||
``` | ||
|
||
## Generating configuration | ||
|
||
Terraform has [experimental support for generating configuration from import blocks](https://developer.hashicorp.com/terraform/language/import/generating-configuration). This feature is not perfect, but it can help you get started with your configuration if you have some pre-existing resources. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters