|
|
|
|
@ -103,28 +103,29 @@ func resourceAwsIamPolicyAttachmentRead(d *schema.ResourceData, meta interface{}
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
policyEntities, err := conn.ListEntitiesForPolicy(&iam.ListEntitiesForPolicyInput{
|
|
|
|
|
PolicyArn: aws.String(arn),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
ul := make([]string, 0)
|
|
|
|
|
rl := make([]string, 0)
|
|
|
|
|
gl := make([]string, 0)
|
|
|
|
|
|
|
|
|
|
ul := make([]string, 0, len(policyEntities.PolicyUsers))
|
|
|
|
|
rl := make([]string, 0, len(policyEntities.PolicyRoles))
|
|
|
|
|
gl := make([]string, 0, len(policyEntities.PolicyGroups))
|
|
|
|
|
|
|
|
|
|
for _, u := range policyEntities.PolicyUsers {
|
|
|
|
|
ul = append(ul, *u.UserName)
|
|
|
|
|
args := iam.ListEntitiesForPolicyInput{
|
|
|
|
|
PolicyArn: aws.String(arn),
|
|
|
|
|
}
|
|
|
|
|
err = conn.ListEntitiesForPolicyPages(&args, func(page *iam.ListEntitiesForPolicyOutput, lastPage bool) bool {
|
|
|
|
|
for _, u := range page.PolicyUsers {
|
|
|
|
|
ul = append(ul, *u.UserName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, r := range policyEntities.PolicyRoles {
|
|
|
|
|
rl = append(rl, *r.RoleName)
|
|
|
|
|
}
|
|
|
|
|
for _, r := range page.PolicyRoles {
|
|
|
|
|
rl = append(rl, *r.RoleName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, g := range policyEntities.PolicyGroups {
|
|
|
|
|
gl = append(gl, *g.GroupName)
|
|
|
|
|
for _, g := range page.PolicyGroups {
|
|
|
|
|
gl = append(gl, *g.GroupName)
|
|
|
|
|
}
|
|
|
|
|
return true
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
userErr := d.Set("users", ul)
|
|
|
|
|
|