DrFaust92 / terraform-provider-bitbucket

Terraform Bitbucket Cloud provider.
https://registry.terraform.io/providers/drfaust92/bitbucket
Mozilla Public License 2.0
36 stars 29 forks source link

bitbucket_branch_restriction users must not use username as it is deprecated and not obtainable #173

Open ChristianAnke opened 10 months ago

ChristianAnke commented 10 months ago

Terraform Version

v1.5.5

Affected Resource(s)

Terraform Configuration Files


resource "bitbucket_branch_restriction" "push" {
  branch_match_kind = "glob"
  branch_type       = null
  kind              = "push"
  owner             = "me"
  pattern           = "main"
  repository        = "repo-name"
  users             = [ "user_name" ]
  value             = 0
}

Expected Behavior

Instead of user_name the UUID or Atlassian ID schould be used

Actual Behavior

The users username can not be obtained other than the user itself. There is no API endpoint providing this information anymore.

Steps to Reproduce

  1. terraform apply

References

https://developer.atlassian.com/cloud/bitbucket/bitbucket-api-changes-gdpr/#removal-of-usernames-from-user-referencing-apis

TizianoPerrucci commented 2 months ago

Due to this issue there is no other way to configure the allowed user on the branch restriction rather then just hardcode the username. Could we get some attention to this ?

Nkmol commented 2 months ago

The API does not seem to support account_id (Atlassian ID) as this is not part of the API account schema, which is weird considering the reference posted. To support this, it would be best to communicate this with Atlassian.

uuid is supported through the API. I am only not sure how to represent this in HCL.

Nkmol commented 1 month ago

A small update, contacted Atlassian about this matter:

  1. username is now officially deprecated from this endpoint, and has been removed from the OpenAPI definition (see https://community.atlassian.com/t5/Bitbucket-questions/Feat-Swagger-V3-Update-account-schema/qaq-p/2694518#U2702105)
  2. A request has been filled to support account_id (Atlassian ID) for this endpoint https://jira.atlassian.com/browse/BCLOUD-23240 (see https://community.atlassian.com/t5/Bitbucket-questions/Feat-REST-allow-Account-ID-to-be-used-to-update-users-in-branch/qaq-p/2694527#U2702107). It will help to vote for the issue if this is something you'd want.

To keep this backwards compatible, and as the API still support post requests with username, I want to try to support both these syntaxes. But strongly advise using the uuid as remote changes cannot be checked with username.