codecutout / terraform-provider-powerbi

Terraform Power BI Provider
MIT License
14 stars 16 forks source link
powerbi terraform-provider

Terraform Provider for Power BI

Test status

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

Installation

Registry

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"
    }
  }
}

Local

If using terraform 0.12 plugins must be installed locally

  1. From the releases section download the zip file for your desired version, operating system and architecture
  2. Extract the zip file into %APPDATA%\terraform.d\plugins for windows, or ~/.terraform.d/plugins for other systems
  3. 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

Usage Example

# 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"
    }
}

Documentation

Provider and resources properties and example usages can be found in this repositories docs folder

Developer Requirements

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".*

Developing the Provider

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.

Build

$ go build

Documentation generation

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

Testing

$ 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:

Running with Terraform on Windows