Check if security group is nil, fixes #2507
Merge pull request #2569 from gaurish/security_group_check

Check if security group is nil, fixes #2507