Hey folks,
I am not yet sure how this update got past me, but I am extremely excited to now be able to test it out. More “accidentally” I discovered yesterday that the Power Platform Terraform Provider is available in experimental, so you can get started testing to deploy your Power Platform using Infrastructure as Code (IaC). In this article, I will give you an overview of why you should care as a Power Platform administrator about this new opportunity and where to get started.
What is Terraform?
Terraform is an open-source Infrastructure as Code (IaC) tool developed by HashiCorp. It allows you to define and provision your entire infrastructure using a declarative language. Using declarative language, you emphasize what you want to achieve, rather than how to achieve it.
Taking this to real life, think about declarative language as you go to a coffee shop and order a caramel macchiato with almond milk. The barista doesn’t need to know how to make it, they follow a predefined recipe or process to create your drink and you focus on the result (the delicious coffee) without worrying about the steps involved. Now let’s switch to an imperative approach (imperative languages are for example Python, Java, Shell Scripting, etc.), you’re the barista this time! You have a detailed recipe card that lists every step: grind the coffee beans, froth the milk, pull the espresso shot, etc. You follow each instruction explicitly, step by step, until you’ve assembled the caramel macchiato.
terraform {
required_providers {
powerplatform = {
source = "microsoft/power-platform"
}
}
}
provider "powerplatform" {
use_cli = true
}
resource "powerplatform_environment" "development" {
display_name = "example_environment"
location = "europe"
azure_region = "northeurope"
environment_type = "Sandbox"
dataverse = {
language_code = "1033"
currency_code = "USD"
domain = "mydomain"
security_group_id = "00000000-0000-0000-0000-000000000000"
}
}
This code example shows how to create a new environment within Power Platform, probably even as a non-professional developer, you will be able to read and understand most of the things happening in there.
How will this help me with Power Platform?
Let’s try to draw the big picture. Back in 2022, Microsoft introduced the North Star Architecture and Landing Zones for Power Platform that gave companies a best practice to scale, secure, govern and extend the Power Platform. Here is the North Star Architecture as an image:
Let’s take this as our planned Power Platform infrastructure. So, whenever there is a request for an environment, you as an administrator need to follow along a list of steps to set up the new environment (or multiple environments, if you have dev, test, q&a, prod environment). You also need to define the environment settings, there are settings and features you don’t or do want to have enabled, setting up the data loss prevention policy (DLP), etc.
And you also have other services you need to set up, creating a new repository within GitHub or DevOps, creating a new Azure Application Insight, setting up an Azure billing policy with pay as you go.
Wouldn’t it be great if you could just deploy all of this without following all the steps to set it up manually? And what about if something changes? Do you also monitor and protocol changes?
That’s were IaC can help you. Of course, in the beginning you will need to set up your “blueprint” or template, like what should happen in which situation, which variables do you need to fill out and which can be static, creating your Terraform configuration files etc. Afterwards, you will be able to fill out only the necessary variables and start the deployment for all these resources. Terraform is also available for other services like Azure and GitHub and will take care of everything for you, based on your definition. So within a couple of minutes, you could have set up a new repository, a Power Platform environment with the right environment settings, DLPs, users, Entra ID security groups, Azure Application Insight and more resources.
Terraform’s primary function is to create, modify, and destroy infrastructure resources to match the desired state described by you within a Terraform configuration. Terraform relies on three commands: plan, apply, and destroy. Before your configuration is carried out, you should always plan the configuration, Terraform will then show you what it will change:
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# powerplatform_environment.dev will be created
+ resource "powerplatform_environment" "dev" {
+ azure_region = (known after apply)
+ billing_policy_id = (known after apply)
+ dataverse = {
+ currency_code = "EUR"
+ domain = (known after apply)
+ language_code = 1033
+ linked_app_id = (known after apply)
+ linked_app_type = (known after apply)
+ linked_app_url = (known after apply)
+ organization_id = (known after apply)
+ security_group_id = "00000000-0000-0000-0000-000000000000"
+ url = (known after apply)
+ version = (known after apply)
}
+ display_name = "github-terraform-test"
+ environment_type = "Sandbox"
+ id = (known after apply)
+ location = "europe"
}
Plan: 1 to add, 0 to change, 0 to destroy.
After you reviewed the changes Terraform will do, you can apply it. You can either run this locally or you can also use services like GitHub and GitHub Actions for more automation and also versioning.
How can I get started with Terraform for Power Platform?
Here are some good resources where you will find more information:
microsoft/terraform-provider-power-platform: Power Platform Terraform Provider (github.com)
Power Platform Terraform Provider (microsoft.github.io)
Terraform Registry Docs overview | microsoft/power-platform
I hope I could give you a good first overview about the opportunities using Terraform to manage Power Platform in the future. I am also working on some sessions regarding this, so stay tuned!
Thanks for reading, I hope you liked it and it will help you! Please don’t hesitate to ask questions.
Marvin
Schreibe einen Kommentar