A Terraform provider that allows the creation and updating of Power BI resources
The Power BI Provider supports Terraform 0.12.x. It may still function on earlier versions but has only been tested on 0.12.x and later versions
If you use Terraform 0.13 or greater, the provider can be installed from the terraform provider registry by specifying the following item in your terraform
terraform {
required_providers {
powerbi = {
source = "codecutout/powerbi"
version = "~>1.3"
}
}
}
If using terraform 0.12 plugins must be installed locally
- From the releases section download the zip file for your desired version, operating system and architecture
- Extract the zip file into
%APPDATA%\terraform.d\plugins
for windows, or~/.terraform.d/plugins
for other systems terraform init
should now detect usage of the provider and apply the plugin
Further details about installing terraform plugs can be found at https://www.terraform.io/docs/plugins/basics.html#installing-plugins
# Configure the Power BI Provider
provider "powerbi" {
tenant_id = "..."
client_id = "..."
client_secret = "..."
username = "..."
password = "..."
}
# Create a workspace
resource "powerbi_workspace" "example" {
name = "Example Workspace"
}
# Create a pbix within the workspace
resource "powerbi_pbix" "example" {
workspace_id = "${powerbi_workspace.example.id}"
name = "My PBIX"
source = "./my-pbix.pbix"
source_hash = "${filemd5(".my-pbix.pbix")}"
datasource {
type = "OData"
url = "https://services.odata.org/V3/(S(kbiqo1qkby04vnobw0li0fcp))/OData/OData.svc"
original_url = "https://services.odata.org/V3/OData/OData.svc"
}
}
Provider and resources properties and example usages can be found in this repositories docs folder
If you're on Windows you'll also need:
For Git Bash for Windows, at the step of "Adjusting your PATH environment", please choose "Use Git and optional Unix tools from Windows Command Prompt".*
If you wish to work on the provider, you'll first need Go installed on your machine (version 1.13+ is required). You'll also need to correctly setup a GOPATH, as well as adding $GOPATH/bin
to your $PATH
.
$ go build
Documentation markdown files are partly generated from terraform schema definitions. To regenreate the documentation from updated schema run
$ go run internal/docgen/cmd/main.go
$ go test -v ./...
The majority of tests in the provider are Acceptance Tests - which provisions real resources in power BI. It's possible to run the acceptance tests with the above command by setting the following enviornment variables:
TF_ACC=1
POWERBI_TENANT_ID
POWERBI_CLIENT_ID
POWERBI_CLIENT_SECRET
POWERBI_USERNAME
POWERBI_PASSWORD
- Run
go build
- This will build and deployterraform-provider-powerbi.exe
- Run
mkdir %APPDATA%\terraform.d\plugins\local.dev\codecutout\powerbi\0.1\windows_amd64
to provison a locally available provider namespace - Move the binary to the local namespace:
move terraform-provider-powerbi.exe %APPDATA%\terraform.d\plugins\local.dev\codecutout\powerbi\0.1\windows_amd64
- Use the custom build provider from Terraform:
terraform {
required_providers {
powerbi = {
source = "local.dev/codecutout/powerbi"
}
}
}