resources: aws: ec2: Check that policy.Statement != nil

This commit is contained in:
Jonathan Gold
2017-11-24 08:17:21 -05:00
committed by James Shubin
parent 9ba9ef1cbf
commit 388a08e13a

View File

@@ -1155,6 +1155,10 @@ func (obj *AwsEc2Res) snsAuthorizeCloudWatch(topicArn string) error {
if err := json.Unmarshal([]byte(*pol), &policy); err != nil { if err := json.Unmarshal([]byte(*pol), &policy); err != nil {
return err return err
} }
// make sure the existing policy statement(s) are returned
if policy.Statement == nil {
return fmt.Errorf("sns policy statement is nil")
}
// construct a policy statement // construct a policy statement
permission := snsStatement{ permission := snsStatement{
Sid: SnsPolicySid, Sid: SnsPolicySid,