// SGStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
// a security group.
SGStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
a security group.
// SGStateRefreshFunc returns a resource . StateRefreshFunc that is used to watch // a security group .
func SGStateRefreshFunc(conn *ec2.EC2, id string) resource.StateRefreshFunc {
	return func() (interface{}, string, error) {
		req := &ec2.DescribeSecurityGroupsInput{
			GroupIds: []*string{aws.String(id)},
		}
		resp, err := conn.DescribeSecurityGroups(req)
		if err != nil {
			if ec2err, ok := err.(awserr.Error); ok {
				if ec2err.Code() == "InvalidSecurityGroupID.NotFound" ||
					ec2err.Code() == "InvalidGroup.NotFound" {
					resp = nil
					err = nil
				}
			}
			if err != nil {
				log.Printf("Error on SGStateRefresh: %s", err)
				return nil, "", err
			}
		}
		if resp == nil {
			return nil, "", nil
		}
		group := resp.SecurityGroups[0]
		return group, "exists", nil
	}
}
func SGStateRefreshFunc ( conn * ec2 . EC2 , id string ) resource . StateRefreshFunc { return func ( ) ( interface { } , string , error ) { req := & ec2 . DescribeSecurityGroupsInput { GroupIds : [ ] * string { aws . String ( id ) } , } resp , err := conn . DescribeSecurityGroups ( req ) if err != nil { if ec2err , ok := err . ( awserr . Error ) ; ok { if ec2err . Code ( ) == " " || ec2err . Code ( ) == " " { resp = nil err = nil } } if err != nil { log . Printf ( " " , err ) return nil , " " , err } } if resp == nil { return nil , " " , nil } group := resp . SecurityGroups [ 0 ] return group , " " , nil } }
SGStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
a security group.
SGStateRefreshFunc returns a resource . StateRefreshFunc that is used to watch a security group .