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

powerplatform_user support environment without dataverse #488

Open
jmservier opened this issue Oct 7, 2024 · 5 comments
Open

powerplatform_user support environment without dataverse #488

jmservier opened this issue Oct 7, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request go Pull requests that update Go code guide guidance documentation and examples resource terraform resource

Comments

@jmservier
Copy link

Dear all,
Firstly thanks for your works.

Description

We would like to declare administrator for non managed environnemnt with Terraform.
With the web interface I can do it:

  1. Select the environment
  2. to the right they are panel "Access" (in french "Acceder") that allow to wiew current admin
    Capture d'écran 2024-10-07 114522
  3. once we click on "Afficher tout" -> "view all" , we can add admin user

What I try

resource "powerplatform_environment" "this" {
  display_name     = local.environment_name
  location         = var.location
  environment_type = var.environment_type == "PROD" ? "Production" : "Sandbox"

}

resource "powerplatform_user" "admin" {
  environment_id = powerplatform_environment.this.id
  security_roles = ["Environment Admin"]
  aad_id         = var.administrator_object_id
  disable_delete = false

}

And the current issue:

powerplatform_environment.this: Creating...
powerplatform_environment.this: Creation complete after 6s [id=xxxxxxxxxxxxxxxxxxxxxx]
powerplatform_user.admin: Creating...
╷
│ Error: Client error when creating _user
│ 
│   with powerplatform_user.admin,
│   on main.tf line 12, in resource "powerplatform_user" "admin":
│   12: resource "powerplatform_user" "admin" {
│ 
│ Unexpected HTTP status code. Expected: [200], received: [409] 409 Conflict
│ | {"error":{"code":"UnlinkedEnvironmentForbiddenOperation","message":"The
│ environment 'xxxxxxxxxxxxxxxxxxxx' is not linked to a new
│ CDS 2.0 instance. The following operation is forbidden for unlinked
│ environments:
│ 'POST/PROVIDERS/MICROSOFT.BUSINESSAPPPLATFORM/SCOPES/ADMIN/ENVIRONMENTS/ADDUSER'","detailUrlType":"NotSpecified"}}

Definition of Done

They are a terraform way (ressource ?) to declare an administrator for non managed environment

@rpothin
Copy link
Contributor

rpothin commented Oct 7, 2024

Hi @jmservier,

Has the environment where you are trying to manage administrators Dataverse enabled? (to confirm this, you can look for the Dataverse version on your environment home page in PPAC like illustrated below)

image

I am not sure your error is related to the fact that your environment is not managed.

Thank you in advance for your answer.
Have a great day.
Raphael

@jmservier
Copy link
Author

As I try to create an environment and after to assign an administrator.
I can not see this web page.

If I create a Production environment with Dataverse enable this will imply to provides a premium licence isn't it ?

Manually (from the web), I am able to create a non managed environment without DataVerse and to assign an administrator.
I would like to do the same with terraform.

@rpothin
Copy link
Contributor

rpothin commented Oct 7, 2024

Thank you for the clarification @jmservier.

I will let the team maintaining this provider provide an answer then 😊
From my perspective they will need to decide if it is something they forgot to cover in the existing user resource or a brand-new requirement (potentially due to the fact that user security roles management in an environment without Dataverse is based on a different API).

@jmservier
Copy link
Author

Thanks @rpothin
They are this Microsoft documentation: https://learn.microsoft.com/en-us/power-platform/admin/database-security
that describe how to assign an administrator without Dataverse.

@mawasile
Copy link
Contributor

mawasile commented Oct 9, 2024

hi @jmservier, @rpothin is correct. To managed user and their security roles using powerplatform_user the environment has to have Dataverse where those information are stored and managed.
We don't support this part with powerplatform_user at the moment

@mawasile mawasile self-assigned this Oct 28, 2024
@mawasile mawasile added enhancement New feature or request go Pull requests that update Go code resource terraform resource guide guidance documentation and examples labels Oct 28, 2024
@mawasile mawasile added this to the Public Preview milestone Oct 28, 2024
@mawasile mawasile changed the title How to assign an environment adminsitrator for non-managed environment ? powerplatform_user support environment without dataverse Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request go Pull requests that update Go code guide guidance documentation and examples resource terraform resource
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants