Skip to content

Commit

Permalink
chore(release): v4.31.1
Browse files Browse the repository at this point in the history
  • Loading branch information
byashimov committed Dec 23, 2024
1 parent 9d58d73 commit ac7ae61
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ nav_order: 1
<!-- Always keep the following header in place: -->
<!--## [MAJOR.MINOR.PATCH] - YYYY-MM-DD -->

## [4.31.1] - 2024-12-23

- Validate whether the `aiven_project.billing_group` field has changed before calling admin API

## [4.31.0] - 2024-12-18

- Add `alloydbomni` BETA resource and datasource
Expand Down
14 changes: 12 additions & 2 deletions internal/sdkprovider/service/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,21 @@ func resourceProjectUpdate(ctx context.Context, d *schema.ResourceData, m interf
return diag.FromErr(err)
}

if billingGroupID, ok := d.GetOk("billing_group"); ok {
// Assigns the project to the billing group if it is not already assigned.
// The endpoints used in resourceProjectAssignToBillingGroup require admin privileges.
// So to make this resource manageable by non-admin users, we need to check if the billing group is already valid
// by making a simple comparison.
// The billing_group is either set in the config file or received by resourceProjectRead from ProjectGET,
// in which it is required https://api.aiven.io/doc/#tag/Project/operation/ProjectGet
// therefore, it is safe to assume that it is always set.
// ProjectUpdate also always returns the billing group.
// Hence, we can compare remote and local values.
billingGroupID := d.Get("billing_group").(string)
if billingGroupID != project.BillingGroupId {
dia := resourceProjectAssignToBillingGroup(
ctx,
d.Get("project").(string),
billingGroupID.(string),
billingGroupID,
client,
d,
)
Expand Down

0 comments on commit ac7ae61

Please sign in to comment.