diff --git a/builder/amazonebs/builder.go b/builder/amazonebs/builder.go index 8822a78fb..8a0c0c71f 100644 --- a/builder/amazonebs/builder.go +++ b/builder/amazonebs/builder.go @@ -29,12 +29,13 @@ type config struct { SecretKey string `mapstructure:"secret_key"` // Information for the source instance - Region string - SourceAmi string `mapstructure:"source_ami"` - InstanceType string `mapstructure:"instance_type"` - SSHUsername string `mapstructure:"ssh_username"` - SSHPort int `mapstructure:"ssh_port"` - SSHTimeout time.Duration + Region string + SourceAmi string `mapstructure:"source_ami"` + InstanceType string `mapstructure:"instance_type"` + SSHUsername string `mapstructure:"ssh_username"` + SSHPort int `mapstructure:"ssh_port"` + SSHTimeout time.Duration + SecurityGroupId string `mapstructure:"security_group_id"` // Configuration of the resulting AMI AMIName string `mapstructure:"ami_name"` diff --git a/builder/amazonebs/step_security_group.go b/builder/amazonebs/step_security_group.go index 65c71cd7b..c35413c90 100644 --- a/builder/amazonebs/step_security_group.go +++ b/builder/amazonebs/step_security_group.go @@ -19,6 +19,12 @@ func (s *stepSecurityGroup) Run(state map[string]interface{}) multistep.StepActi ec2conn := state["ec2"].(*ec2.EC2) ui := state["ui"].(packer.Ui) + if config.SecurityGroupId != "" { + log.Printf("Using specified security group: %s", config.SecurityGroupId) + state["securityGroupId"] = config.SecurityGroupId + return multistep.ActionContinue + } + // Create the group ui.Say("Creating temporary security group for this instance...") groupName := fmt.Sprintf("packer %s", hex.EncodeToString(identifier.NewUUID().Raw()))