Skip to content

Commit f40f3c1

Browse files
authored
fix(iam_policy): set organization_id to optional (#1387)
1 parent 854d1af commit f40f3c1

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

scaleway/resource_iam_policy.go

+15-8
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ func resourceScalewayIamPolicy() *schema.Resource {
4747
Computed: true,
4848
Description: "Whether or not the policy is editable.",
4949
},
50-
"organization_id": organizationIDSchema(),
50+
"organization_id": {
51+
Type: schema.TypeString,
52+
Optional: true,
53+
Computed: true,
54+
Description: "ID of organization the policy is linked to.",
55+
},
5156
"user_id": {
5257
Type: schema.TypeString,
5358
Optional: true,
@@ -109,14 +114,16 @@ func resourceScalewayIamPolicy() *schema.Resource {
109114

110115
func resourceScalewayIamPolicyCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
111116
api := iamAPI(meta)
117+
112118
pol, err := api.CreatePolicy(&iam.CreatePolicyRequest{
113-
Name: expandOrGenerateString(d.Get("name"), "policy-"),
114-
Description: d.Get("description").(string),
115-
Rules: expandPolicyRuleSpecs(d.Get("rule")),
116-
UserID: expandStringPtr(d.Get("user_id")),
117-
GroupID: expandStringPtr(d.Get("group_id")),
118-
ApplicationID: expandStringPtr(d.Get("application_id")),
119-
NoPrincipal: expandBoolPtr(d.Get("no_principal")),
119+
Name: expandOrGenerateString(d.Get("name"), "policy-"),
120+
Description: d.Get("description").(string),
121+
Rules: expandPolicyRuleSpecs(d.Get("rule")),
122+
UserID: expandStringPtr(d.Get("user_id")),
123+
GroupID: expandStringPtr(d.Get("group_id")),
124+
ApplicationID: expandStringPtr(d.Get("application_id")),
125+
NoPrincipal: expandBoolPtr(d.Get("no_principal")),
126+
OrganizationID: d.Get("organization_id").(string),
120127
}, scw.WithContext(ctx))
121128
if err != nil {
122129
return diag.FromErr(err)

0 commit comments

Comments
 (0)