Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error during the creation of fabric_domain_workspace_assignments #183

Open
1 task done
ccaeand opened this issue Jan 7, 2025 · 3 comments Β· May be fixed by #182
Open
1 task done

[BUG] Error during the creation of fabric_domain_workspace_assignments #183

ccaeand opened this issue Jan 7, 2025 · 3 comments Β· May be fixed by #182
Assignees
Labels
bug Something isn't working duplicate This issue or pull request already exists
Milestone

Comments

@ccaeand
Copy link

ccaeand commented Jan 7, 2025

πŸ› What happened?

While applying a configuration using version 0.1.0-beta.7, we encountered an inconsistent result error during the creation of fabric_domain_workspace_assignments resources.

πŸ”¬ How to reproduce?

No response

πŸ—οΈ Code Sample / Log

Error: Provider produced inconsistent result after apply
β”‚
β”‚ When applying changes to
β”‚ module.fabric_resources.fabric_domain_workspace_assignments.domain_assignment["test-domain1-curated-prod-ws"],
β”‚ provider "provider["registry.terraform.io/microsoft/fabric"]" produced an
β”‚ unexpected new value: .workspace_ids: actual set element
β”‚ cty.StringVal("4b474cf8-937f-4bc7-999d-71234560d") does not correlate
β”‚ with any element in plan.
β”‚
β”‚ This is a bug in the provider, which should be reported in the provider's
β”‚ own issue tracker.
β•΅
β•·
β”‚ Error: Provider produced inconsistent result after apply
β”‚
β”‚ When applying changes to
β”‚ module.fabric_resources.fabric_domain_workspace_assignments.domain_assignment["test-domain1-curated-prod-ws"],
β”‚ provider "provider["registry.terraform.io/microsoft/fabric"]" produced an
β”‚ unexpected new value: .workspace_ids: length changed from 1 to 2.
β”‚
β”‚ This is a bug in the provider, which should be reported in the provider's
β”‚ own issue tracker.

πŸ“· Screenshots

No response

πŸ“ˆ Expected behavior

No response

🌌 Environment (Provider Version)

0.1.0-beta.7

🌌 Environment (Terraform Version)

v1.10.3

🌌 Environment (OS)

Linux

πŸ“Ž Additional context

No response

πŸ”° Code of Conduct

  • I agree to follow this project's Code of Conduct.
@ccaeand ccaeand added the bug Something isn't working label Jan 7, 2025
@ccaeand ccaeand changed the title [BUG] [BUG]Error during the creation of fabric_domain_workspace_assignments Jan 7, 2025
@DariuszPorowski
Copy link
Member

Hi @ccaeand thank you for taking the time for reporting.

May I ask you to provide HCL code what you use that cause this issue? It will help with investigating this bug.

@DariuszPorowski DariuszPorowski changed the title [BUG]Error during the creation of fabric_domain_workspace_assignments [BUG] Error during the creation of fabric_domain_workspace_assignments Jan 8, 2025
@ccaeand
Copy link
Author

ccaeand commented Jan 8, 2025

Hi @DariuszPorowski - Please find below HCL code snippet and relative files for completeness.

Assign Workspaces to Domains

resource "fabric_domain_workspace_assignments" "domain_assignment" {
  for_each = { for ws in var.workspaces : ws.name => ws }

  domain_id     = each.value.domain_id
  workspace_ids = [fabric_workspace.workspace[each.key].id]

  lifecycle {
    ignore_changes = [workspace_ids]
  }
}

variable def:

variable "workspaces" {
  description = "List of workspaces with their details and items"
  type = list(object({
    name           = string
    description    = optional(string)
    identity_type  = string
    domain_id      = string
    capacity_id    = string
    items = object({
      lakehouse = object({
        name          = string
        configuration = optional(map(string))
      })
      notebook = object({
        name = string
      })
    })
  }))
}

variable "role_assignments" {
  description = "List of workspace role assignments"
  type = list(object({
    workspace_name = string
    role           = string
    principal_id   = string
    principal_type = string
  }))
}

example config.yaml structure:

# workspaces:
  - name: test-domain1-staging-dev-ws
    description: "Test Workspace"
    identity_type: SystemAssigned
    domain_id: "xxxxxxxxxxxxxxxxxxxxxx"
    capacity_id: "xxxxxxxxxxxxxxxxxxxxxx"
    items:
      lakehouse:
        name: test_domain1_staging_dev_lh01
        configuration:
          enable_schemas: true
      notebook:
        name: test-domain1-staging-dev-notebook-1

  - name: test-domain1-curated-prod-ws
    description: "Test Workspace"
    identity_type: SystemAssigned
    domain_id: "xxxxxxxxxxxxxxxxxxxxx"
    capacity_id: "xxxxxxxxxxxxxxxxxxxxxxxxx"
    items:
      lakehouse:
        name: test_domain1_curated_prod_lh01
        configuration:
          enable_schemas: true
      notebook:
        name: test-domain1-curated-prod-notebook-1

# role_assignments:
  - workspace_name: test-domain1-staging-dev-ws
    role: Contributor
    principal_id: "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
    principal_type: User

  - workspace_name: test-domain1-staging-dev-ws
    role: Admin
    principal_id: "xxxxxxxxxxxxxxxxxxxxx"
    principal_type: Group

  - workspace_name: test-domain1-curated-prod-ws
    role: Admin
    principal_id: "xxxxxxxxxxxxxxxxxxxxxxxx"
    principal_type: User

@DariuszPorowski
Copy link
Member

duplicate of #174

Hi @ccaeand Thank you

You are trying to assign workspaces to the domain, but you are taking workspace as subject for assignment, so your result is multiple instances of domain_workspace_assigments (for_each on workspaces) but must be only 1 per domain - domain is subject, not workspace.

Potential workaround for now:

resource "fabric_domain_workspace_assignments" "this" {
  domain_id     = fabric_domain.this.id
  workspace_ids = [for ws in fabric_workspace.this : ws.id]
}

It will be fixed in PR #182

@DariuszPorowski DariuszPorowski self-assigned this Jan 8, 2025
@DariuszPorowski DariuszPorowski added this to the 2025-01 milestone Jan 8, 2025
@DariuszPorowski DariuszPorowski added the duplicate This issue or pull request already exists label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
2 participants