Skip to content

Importing an existing powerplatform_user resource fails even when using the documented import syntax. #1121

@AdamCoulterOz

Description

@AdamCoulterOz

Describe the bug

Importing an existing powerplatform_user resource fails even when using the documented import syntax.

The resource's import path only passes through id, but the subsequent read path requires environment_id to already be present in state. As a result, terraform import prepares the import and then fails during refresh with:

Error: Invalid State

Environment ID is required and cannot be null or unknown

This makes the documented import flow unusable for existing Dataverse users.

Sample Terraform Code

resource "powerplatform_user" "example" {
  environment_id = "00000000-0000-0000-0000-000000000001"
  aad_id         = "00000000-0000-0000-0000-000000000002"
  security_roles = [
    "11111111-1111-1111-1111-111111111111"
  ]
  disable_delete = false
}

Expected behavior

Running terraform import powerplatform_user.example 00000000-0000-0000-0000-000000000002 should import the existing user successfully and hydrate the resource state so that a subsequent terraform plan can compare the imported user with configuration.

Instead, the import fails during refresh because environment_id is still null/unknown in state.

System Information

  • Provider Version: 4.1.1
  • OS & Version: macOS (darwin arm64); also reproduced in Azure Pipelines on Linux

Additional context

  • The provider docs currently state that user resources can be imported using the Entra Object ID.
  • The relevant implementation appears to be:
    • ImportState: passthrough of only id
    • Read: validates environment_id before attempting lookup
  • Reproduction command:
terraform import powerplatform_user.example 00000000-0000-0000-0000-000000000002
  • Observed failure:
powerplatform_user.example: Import prepared!
powerplatform_user.example: Refreshing state... [id=00000000-0000-0000-0000-000000000002]

Error: Invalid State

Environment ID is required and cannot be null or unknown

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcommunityRequest or issue originated from a customer or community request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions