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

Import of an organization is not possible without instance level permission #216

Open
2 tasks done
yann-soubeyrand opened this issue Jan 27, 2025 · 7 comments
Open
2 tasks done
Labels
question Further information is requested resources

Comments

@yann-soubeyrand
Copy link

Preflight Checklist

  • I could not find a solution in the documentation, the existing issues or discussions
  • I have joined the ZITADEL chat

Version

2.0.2

ZITADEL Version

v2.67.1

Describe the problem caused by this bug

An organization cannot be imported when the user is “only” org owner and has no instance level permission. This does not allow setting the organization name, nor getting its primary domain.

To reproduce

  1. Create a service user and give it the org owner role.
  2. Create a key and configure Terraform to use it.
  3. Try to import the organization: terraform import zitadel_org.imported '123456789012345678'.

Result:

Error: error while getting org by id 123456789012345678: rpc error: code = PermissionDenied desc = No matching permissions found (AUTH-5mWD2)

Screenshots

No response

Expected behavior

As an org owner, I would like to be able to import my organization.

Relevant Configuration

No response

Additional Context

No response

@yann-soubeyrand yann-soubeyrand added the bug Something isn't working label Jan 27, 2025
@muhlemmer muhlemmer added the auth label Jan 27, 2025
@muhlemmer
Copy link

This is correct, as the ORG_** memberships are assigned on organization objects. You can't have such membership on one org and then expect the ability to create a new org. The new org didn't exist yet and therefore the user can't be the ORG_OWNER. Creation or import of organizations always need instance level membership because the org belongs to the instance.

We have another role which is probably suitable for your use-case: IAM_ORG_MANAGER

@muhlemmer muhlemmer closed this as not planned Won't fix, can't repro, duplicate, stale Jan 27, 2025
@yann-soubeyrand
Copy link
Author

@muhlemmer of course, one cannot create an org without permissions at the instance level, however importing it (for example to modify its name) should be possible, right?

@muhlemmer
Copy link

The import endpoint of zitadel allows setting of orgMembers. I'm not sure how this translates to terraform, I'm not familiar with this repo, just handling the inbox.

Let me know if you can;t figure it out and I will re-open and ping someone.

@yann-soubeyrand
Copy link
Author

I think we do not speak of the same import: in Terraform, one can import an existing resource, to manage it using Terraform configuration.

An instance admin can create an organization, create a service user giving it org owner role on this new organization and I would like to use this service user to import the organization in Terraform to further manage it. But it’s actually not possible at the time, because it seems that there is no management API endpoint to get an organization by ID.

@muhlemmer
Copy link

When using the resource API (v2) the create organization already returns the organization ID in the response: https://zitadel.com/docs/apis/resources/org_service_v2/organization-service-add-organization

@muhlemmer muhlemmer added question Further information is requested resources and removed bug Something isn't working auth labels Jan 28, 2025
@muhlemmer muhlemmer reopened this Jan 28, 2025
@muhlemmer
Copy link

@stebenz can you have a look to above conversation and give a suggestion? I believe our APIs are fully capable of supporting the desired use-case, I'm just not sure how that translates to terraform.

@stebenz
Copy link
Contributor

stebenz commented Jan 28, 2025

We would need to rework the org resource in terraform to use the new resource API, currently the admin API is still used.

func get(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested resources
Projects
Status: Done
Development

No branches or pull requests

3 participants