@@ -171,6 +171,10 @@ func awsPermissionsRead(ctx context.Context, d *schema.ResourceData, m interface
171
171
return diag .FromErr (err )
172
172
}
173
173
174
+ // The hash is created from customer managed policies and managed policies
175
+ // matching the role key.
176
+ hash := sha256 .New ()
177
+
174
178
var customerPoliciesAttr []map [string ]string
175
179
for _ , policy := range customerPolicies {
176
180
if roleKey == policy .Artifact {
@@ -179,6 +183,10 @@ func awsPermissionsRead(ctx context.Context, d *schema.ResourceData, m interface
179
183
keyName : policy .Name ,
180
184
keyPolicy : policy .Policy ,
181
185
})
186
+ hash .Write ([]byte (policy .Artifact ))
187
+ hash .Write ([]byte (policy .Feature .Name ))
188
+ hash .Write ([]byte (policy .Name ))
189
+ hash .Write ([]byte (policy .Policy ))
182
190
}
183
191
}
184
192
if err := d .Set (keyCustomerManagedPolicies , customerPoliciesAttr ); err != nil {
@@ -189,23 +197,14 @@ func awsPermissionsRead(ctx context.Context, d *schema.ResourceData, m interface
189
197
for _ , policy := range managedPolicies {
190
198
if roleKey == policy .Artifact {
191
199
managedPoliciesAttr = append (managedPoliciesAttr , policy .Name )
200
+ hash .Write ([]byte (policy .Artifact ))
201
+ hash .Write ([]byte (policy .Name ))
192
202
}
193
203
}
194
204
if err := d .Set (keyManagedPolicies , managedPoliciesAttr ); err != nil {
195
205
return diag .FromErr (err )
196
206
}
197
207
198
- hash := sha256 .New ()
199
- for _ , policy := range customerPolicies {
200
- hash .Write ([]byte (policy .Artifact ))
201
- hash .Write ([]byte (policy .Feature .Name ))
202
- hash .Write ([]byte (policy .Name ))
203
- hash .Write ([]byte (policy .Policy ))
204
- }
205
- for _ , policy := range managedPolicies {
206
- hash .Write ([]byte (policy .Artifact ))
207
- hash .Write ([]byte (policy .Name ))
208
- }
209
208
d .SetId (fmt .Sprintf ("%x" , hash .Sum (nil )))
210
209
211
210
return nil
0 commit comments