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

[FEATURE] Export of role collection assignments #191

Open
Kaefermade opened this issue Nov 28, 2024 · 6 comments
Open

[FEATURE] Export of role collection assignments #191

Kaefermade opened this issue Nov 28, 2024 · 6 comments
Labels
wontfix This will not be worked on

Comments

@Kaefermade
Copy link

What area do you want to see improved?

CLI commands

Is your feature request related to a problem? Please describe.

It would be useful to be able to export role collection assignments. Even if not by default (all) without specifying the resources to be exported, an optional function for this would be helpful.

Describe the solution you would like

Adding the option for resource btp_subaccount_role_collection_assignment

Describe alternatives you have considered

No response

Additional context

No response

@Kaefermade Kaefermade added enhancement New feature or request pending-decision Decision if implementation will happen is pending labels Nov 28, 2024
Copy link

Thanks for the feature request. We evaluate it and update the issue accordingly.

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@lechnerc77 lechnerc77 added wontfix This will not be worked on and removed enhancement New feature or request pending-decision Decision if implementation will happen is pending labels Nov 29, 2024
@lechnerc77
Copy link
Member

@Kaefermade thanks for the feature request. However, we can only export resources into configurations that support the import in the Terraform Provider for SAP BTP. There are some limitations with respect to the import of resources due to restrictions in the underlying APIs. The limitations concerning the import are listed in the Terraform provider (Import).

We will also make this more transparent in the documentation of the exporter to be transparent about the suppoorted features.

@Kaefermade
Copy link
Author

Kaefermade commented Nov 29, 2024

@lechnerc77 I should probably have been more precise. Looking back, my feature request is actually misleading. My goal is to export users and their assigned roles. Since the creation of users with the provider was only possible via the resource btp_subaccount_role_assignment, I asked for an implementation of this. I only realized again after the feature request that there is no data source for this. Here is an example of how I worked around the problem of the missing data source for role collection assignments in order to copy the users from one subaccount to another.

locals {
  source_subaccount = 
  target_subaccount = 

  user_role_assignments = flatten([
    for user_name, user in data.btp_subaccount_user.someone : [
      for role_collection in user.role_collections : {
        user_name            = user.user_name
        role_collection_name = role_collection
      }
    ]
  ])
}

data "btp_subaccount_users" "defaultidp" {
  subaccount_id = local.source_subaccount
}

data "btp_subaccount_user" "someone" {
  for_each      = { for user in data.btp_subaccount_users.defaultidp.values : user => user }
  subaccount_id = local.source_subaccount
  user_name     = each.value
}

resource "btp_subaccount_role_collection_assignment" "assignment" {
  for_each             = { for idx, assignment in local.user_role_assignments : idx => assignment }
  subaccount_id        = local.target_subaccount
  user_name            = each.value.user_name
  role_collection_name = each.value.role_collection_name
}

I therefore thought that it would be possible to realize something like this with the Exporter. But if there is no import for this, it is understandable.

@lechnerc77 lechnerc77 added needs-triage Issue needs to be triaged enhancement New feature or request pending-decision Decision if implementation will happen is pending and removed wontfix This will not be worked on labels Nov 29, 2024
@lechnerc77
Copy link
Member

@Kaefermade thanks for elaborating more on the use case and thanks for sharing the code snippet. We will look into the setup and validate how to move forward. I put the issue back to the original status.

@lechnerc77
Copy link
Member

@Kaefermade short update: I reviewed the overall flow for the role collections as the import must be supported by the provider. As the provider is built on top of the BTP CLI server we are restricted to the functionality provided there. This API does not provide a READ functionality for the role collection assignment. The READ functionality is a prerequisite to support the import on the resource

Your approach looks good and orchestrating the corresponding API endpoints would probably work to mitigate the missing READ functionality for role collection assignments. However, this mitigation would only be feasible for role collections assigned to a user. When the assignment was executed for a group or attributes the approach would not work. Consequently this type of role collection assignment cannot be covered and could not be imported.

We will continue the discussion internally on the best and most sustainable approach to handle this.

@lechnerc77
Copy link
Member

@Kaefermade update after the internal discussion. Technically it would be possible to integrate the flow you presented to enable the import of role collection assignments to users. However, this would still leave the gap with regards to role collection assignment to groups and attributes.
To have a consistent implementation the flow would have to become part of the Terraform provider (namely the resource role_collection_assignment and its READ functionality) and the import functionality of the resource including the aforementioned gaps.

After internal discussion we decided against such a implementation in the provider as this workaround would only partially cover the requirements for an import of role collections. We are pushing that the existing APIs that are available to cover all scenarios of role collections will be integrated into the BTP CLI server that we technically rely on.

As there is not timeline until when this will be implemented in the on CLI server side, we will have this gap in the exporter.

I will leave this issue open, to post updates on this topic, once available.

@lechnerc77 lechnerc77 added wontfix This will not be worked on and removed enhancement New feature or request needs-triage Issue needs to be triaged pending-decision Decision if implementation will happen is pending labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants