Skip to content

Commit

Permalink
fix(policy): principal and no_principal conflict (#1399)
Browse files Browse the repository at this point in the history
  • Loading branch information
kindermoumoute committed Jul 29, 2022
1 parent 8530f08 commit f6b5e81
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scaleway/resource_iam_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func resourceScalewayIamPolicyCreate(ctx context.Context, d *schema.ResourceData
UserID: expandStringPtr(d.Get("user_id")),
GroupID: expandStringPtr(d.Get("group_id")),
ApplicationID: expandStringPtr(d.Get("application_id")),
NoPrincipal: expandBoolPtr(d.Get("no_principal")),
NoPrincipal: expandBoolPtr(getBool(d, "no_principal")),
OrganizationID: d.Get("organization_id").(string),
}, scw.WithContext(ctx))
if err != nil {
Expand Down Expand Up @@ -199,11 +199,15 @@ func resourceScalewayIamPolicyUpdate(ctx context.Context, d *schema.ResourceData
}
if d.HasChange("group_id") {
hasUpdated = true
req.UserID = expandStringPtr(d.Get("group_id"))
req.GroupID = expandStringPtr(d.Get("group_id"))
}
if d.HasChange("application_id") {
hasUpdated = true
req.UserID = expandStringPtr(d.Get("application_id"))
req.ApplicationID = expandStringPtr(d.Get("application_id"))
}
if d.HasChange("no_principal") {
hasUpdated = true
req.NoPrincipal = expandBoolPtr(getBool(d, "no_principal"))
}
if hasUpdated {
_, err := api.UpdatePolicy(req, scw.WithContext(ctx))
Expand Down

0 comments on commit f6b5e81

Please sign in to comment.