From 56b5e97bf4edc451f62881ecc47619fd319089ed Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Wed, 18 Jan 2017 15:25:31 -0800 Subject: [PATCH] verify given security group --- builder/amazon/common/step_security_group.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/builder/amazon/common/step_security_group.go b/builder/amazon/common/step_security_group.go index 4900b1117..c96b20bf4 100644 --- a/builder/amazon/common/step_security_group.go +++ b/builder/amazon/common/step_security_group.go @@ -27,6 +27,17 @@ func (s *StepSecurityGroup) Run(state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) if len(s.SecurityGroupIds) > 0 { + _, err := ec2conn.DescribeSecurityGroups( + &ec2.DescribeSecurityGroupsInput{ + GroupIds: aws.StringSlice(s.SecurityGroupIds), + }, + ) + if err != nil { + err := fmt.Errorf("Couldn't find specified security group: %s", err) + log.Printf("[DEBUG] %s", err.Error()) + state.Put("error", err) + return multistep.ActionHalt + } log.Printf("Using specified security groups: %v", s.SecurityGroupIds) state.Put("securityGroupIds", s.SecurityGroupIds) return multistep.ActionContinue