From 388a08e13a606e9fb05117ea22363cb4e05b3aff Mon Sep 17 00:00:00 2001 From: Jonathan Gold Date: Fri, 24 Nov 2017 08:17:21 -0500 Subject: [PATCH] resources: aws: ec2: Check that policy.Statement != nil --- resources/aws_ec2.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/aws_ec2.go b/resources/aws_ec2.go index 3c9a7c58..58a62716 100644 --- a/resources/aws_ec2.go +++ b/resources/aws_ec2.go @@ -1155,6 +1155,10 @@ func (obj *AwsEc2Res) snsAuthorizeCloudWatch(topicArn string) error { if err := json.Unmarshal([]byte(*pol), &policy); err != nil { 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 permission := snsStatement{ Sid: SnsPolicySid,