Commit c710323f authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/amazon/*: Fix failing tests from rebase of VPC

parent f94500b3
...@@ -22,7 +22,10 @@ func TestArtifactId(t *testing.T) { ...@@ -22,7 +22,10 @@ func TestArtifactId(t *testing.T) {
amis["east"] = "foo" amis["east"] = "foo"
amis["west"] = "bar" amis["west"] = "bar"
a := &Artifact{amis, nil} a := &Artifact{
Amis: amis,
}
result := a.Id() result := a.Id()
assert.Equal(result, expected, "should match output") assert.Equal(result, expected, "should match output")
} }
...@@ -39,7 +42,7 @@ west: bar` ...@@ -39,7 +42,7 @@ west: bar`
amis["east"] = "foo" amis["east"] = "foo"
amis["west"] = "bar" amis["west"] = "bar"
a := &Artifact{amis, nil} a := &Artifact{Amis: amis}
result := a.String() result := a.String()
assert.Equal(result, expected, "should match output") assert.Equal(result, expected, "should match output")
} }
...@@ -12,6 +12,7 @@ type StepRunSourceInstance struct { ...@@ -12,6 +12,7 @@ type StepRunSourceInstance struct {
ExpectedRootDevice string ExpectedRootDevice string
InstanceType string InstanceType string
SourceAMI string SourceAMI string
SubnetId string
instance *ec2.Instance instance *ec2.Instance
} }
...@@ -29,7 +30,7 @@ func (s *StepRunSourceInstance) Run(state map[string]interface{}) multistep.Step ...@@ -29,7 +30,7 @@ func (s *StepRunSourceInstance) Run(state map[string]interface{}) multistep.Step
MinCount: 0, MinCount: 0,
MaxCount: 0, MaxCount: 0,
SecurityGroups: []ec2.SecurityGroup{ec2.SecurityGroup{Id: securityGroupId}}, SecurityGroups: []ec2.SecurityGroup{ec2.SecurityGroup{Id: securityGroupId}},
SubnetId: config.SubnetId, SubnetId: s.SubnetId,
} }
ui.Say("Launching a source AWS instance...") ui.Say("Launching a source AWS instance...")
......
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
type StepSecurityGroup struct { type StepSecurityGroup struct {
SecurityGroupId string SecurityGroupId string
SSHPort int SSHPort int
VpcId string
createdGroupId string createdGroupId string
} }
...@@ -35,7 +36,12 @@ func (s *StepSecurityGroup) Run(state map[string]interface{}) multistep.StepActi ...@@ -35,7 +36,12 @@ func (s *StepSecurityGroup) Run(state map[string]interface{}) multistep.StepActi
ui.Say("Creating temporary security group for this instance...") ui.Say("Creating temporary security group for this instance...")
groupName := fmt.Sprintf("packer %s", hex.EncodeToString(identifier.NewUUID().Raw())) groupName := fmt.Sprintf("packer %s", hex.EncodeToString(identifier.NewUUID().Raw()))
log.Printf("Temporary group name: %s", groupName) log.Printf("Temporary group name: %s", groupName)
groupResp, err := ec2conn.CreateSecurityGroup(ec2.SecurityGroup{Name: groupName, Description: "Temporary group for Packer", VpcId: config.VpcId}) group := ec2.SecurityGroup{
Name: groupName,
Description: "Temporary group for Packer",
VpcId: s.VpcId,
}
groupResp, err := ec2conn.CreateSecurityGroup(group)
if err != nil { if err != nil {
ui.Error(err.Error()) ui.Error(err.Error())
return multistep.ActionHalt return multistep.ActionHalt
......
...@@ -97,6 +97,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe ...@@ -97,6 +97,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
ExpectedRootDevice: "ebs", ExpectedRootDevice: "ebs",
InstanceType: b.config.InstanceType, InstanceType: b.config.InstanceType,
SourceAMI: b.config.SourceAmi, SourceAMI: b.config.SourceAmi,
SubnetId: b.config.SubnetId,
}, },
&common.StepConnectSSH{ &common.StepConnectSSH{
SSHAddress: awscommon.SSHAddress(b.config.SSHPort), SSHAddress: awscommon.SSHAddress(b.config.SSHPort),
......
...@@ -103,6 +103,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe ...@@ -103,6 +103,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
ExpectedRootDevice: "instance-store", ExpectedRootDevice: "instance-store",
InstanceType: b.config.InstanceType, InstanceType: b.config.InstanceType,
SourceAMI: b.config.SourceAmi, SourceAMI: b.config.SourceAmi,
SubnetId: b.config.SubnetId,
}, },
&common.StepConnectSSH{ &common.StepConnectSSH{
SSHAddress: awscommon.SSHAddress(b.config.SSHPort), SSHAddress: awscommon.SSHAddress(b.config.SSHPort),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment