Check errors when parsing JSON on IAM policies

We weren't checking the error code, and this led to #5522
This commit is contained in:
Justin Santa Barbara 2018-07-27 00:54:21 -04:00
parent 8169f14124
commit 3ddf598448
1 changed files with 4 additions and 1 deletions

View File

@ -189,7 +189,10 @@ func (b *IAMModelBuilder) buildIAMTasks(igRole kops.InstanceGroupRole, iamName s
}
statements := make([]*iam.Statement, 0)
json.Unmarshal([]byte(additionalPolicy), &statements)
if err := json.Unmarshal([]byte(additionalPolicy), &statements); err != nil {
return fmt.Errorf("additionalPolicy %q is invalid: %v", strings.ToLower(string(igRole)), err)
}
p.Statement = append(p.Statement, statements...)
policy, err := p.AsJSON()