Skip to content

Publisher Resource & Datasource #1133

@AdamCoulterOz

Description

@AdamCoulterOz

User Story

As a Terraform user, I want to manage Dataverse publishers through Terraform so that I can standardize solution publisher metadata, prefixes, and related records as code across Power Platform environments.

Use case: A platform team wants to provision and look up a reusable Dataverse publisher before creating unmanaged solutions, ensuring solution prefixes, choice value prefix behavior, and contact/address metadata are consistent and automated across environments.

Resource

  • Resource Name: powerplatform_publisher
  • Data Source Name: powerplatform_publisher
  • Service Name: Dataverse Publisher
  • Documentation Link: Publisher table/entity reference

Potential Terraform Configuration

resource "powerplatform_publisher" "example" {
  environment_id         = "00000000-0000-0000-0000-000000000001" # required
  uniquename             = "contoso" # required
  friendly_name          = "Contoso Publisher" # required
  customization_prefix   = "cts" # required

  # optional; if omitted, provider derives the same default used by the Power Apps UI
  customization_option_value_prefix = 77074

  description            = "Terraform-managed Dataverse publisher"
  email_address          = "publisher@contoso.example"
  supporting_website_url = "https://contoso.example"

  address = [
    {
      slot        = 1 # required, must be 1 or 2
      line1       = "1 Collins Street"
      city        = "Melbourne"
      country     = "Australia"
      postal_code = "3000"
      telephone1  = "+61-3-5555-0101"
    },
    {
      slot        = 2 # required, must be 1 or 2
      line1       = "100 Queen Street"
      city        = "Auckland"
      country     = "New Zealand"
      postal_code = "1010"
      telephone1  = "+64-9-555-0102"
    }
  ]
}

data "powerplatform_publisher" "example" {
  environment_id = "00000000-0000-0000-0000-000000000001"
  uniquename     = "contoso"
}

Additional Validation Rules

  • environment_id is required and must reference a Dataverse-enabled environment.
  • uniquename is required and treated as replacement-only.
  • friendly_name is required.
  • customization_prefix is required.
  • customization_option_value_prefix is optional/computed; when omitted, derive it from customization_prefix using the same algorithm as the Power Apps publisher UI.
  • address may contain at most 2 entries.
  • address.slot is required for each entry and must be either 1 or 2.
  • Only one address block may target a given slot.
  • Resource id should be the raw Dataverse publisherid.
  • Import should accept composite form <environment_id>_<publisher_id> and store the raw publisherid as state id.
  • Data source lookup should support either id or uniquename.

API documentation

Action Verb URL Status Codes Comments
Create POST /api/data/v9.2/publishers 201, 204 Creates publisher, then provider reads back by returned publisherid.
Read GET /api/data/v9.2/publishers({publisherid}) 200, 403, 404 Primary read path for resource.
Read by unique name GET /api/data/v9.2/publishers?$filter=uniquename eq '{uniquename}' 200, 403, 404 Used by data source and duplicate detection.
Update PATCH /api/data/v9.2/publishers({publisherid}) 204 Updates mutable publisher fields and address slot fields.
Delete DELETE /api/data/v9.2/publishers({publisherid}) 204, 403, 404 Deletes publisher if present.

JSON

{
  "uniquename": "contoso",
  "friendlyname": "Contoso Publisher",
  "customizationprefix": "cts",
  "customizationoptionvalueprefix": 77074,
  "description": "Terraform-managed Dataverse publisher",
  "emailaddress": "publisher@contoso.example",
  "supportingwebsiteurl": "https://contoso.example",
  "address1_line1": "1 Collins Street",
  "address1_city": "Melbourne",
  "address1_country": "Australia",
  "address1_postalcode": "3000",
  "address1_telephone1": "+61-3-5555-0101",
  "address2_line1": "100 Queen Street",
  "address2_city": "Auckland",
  "address2_country": "New Zealand",
  "address2_postalcode": "1010",
  "address2_telephone1": "+64-9-555-0102"
}

Definition of Done

  • Data Transfer Objects (dtos) in dto.go
  • Resource and Data Source Models in models.go
  • API Client functions in api_publisher.go
  • Resource Implementation in resource_publisher.go
  • Data Source Implementation in datasource_publisher.go
  • Unit Tests in resource_publisher_test.go and datasource_publisher_test.go for Happy Path, Error conditions, and boundary cases
  • Acceptance Tests for resource and data source Happy Path
  • Resource and data source added to provider.go and provider_test.go
  • Example in the /examples folder
  • Schema documented using MarkdownDescription
  • Change log entry changie new -k added
  • Run make precommit before PR

Metadata

Metadata

Assignees

Labels

communityRequest or issue originated from a customer or community requestenhancementNew feature or requestresourceterraform resource

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions