Merge pull request #5773 from hashicorp/fix5705
Use SDK's InstanceReady waiter
This commit is contained in:
commit
2ce3ca1538
|
@ -175,19 +175,18 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
|
||||||
ui.Message(fmt.Sprintf("Instance ID: %s", instanceId))
|
ui.Message(fmt.Sprintf("Instance ID: %s", instanceId))
|
||||||
ui.Say(fmt.Sprintf("Waiting for instance (%v) to become ready...", instanceId))
|
ui.Say(fmt.Sprintf("Waiting for instance (%v) to become ready...", instanceId))
|
||||||
|
|
||||||
describeInstanceStatus := &ec2.DescribeInstanceStatusInput{
|
describeInstance := &ec2.DescribeInstancesInput{
|
||||||
InstanceIds: []*string{aws.String(instanceId)},
|
InstanceIds: []*string{aws.String(instanceId)},
|
||||||
}
|
}
|
||||||
if err := ec2conn.WaitUntilInstanceStatusOk(describeInstanceStatus); err != nil {
|
if err := ec2conn.WaitUntilInstanceRunning(describeInstance); err != nil {
|
||||||
err := fmt.Errorf("Error waiting for instance (%s) to become ready: %s", instanceId, err)
|
err := fmt.Errorf("Error waiting for instance (%s) to become ready: %s", instanceId, err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
r, err := ec2conn.DescribeInstances(&ec2.DescribeInstancesInput{
|
r, err := ec2conn.DescribeInstances(describeInstance)
|
||||||
InstanceIds: []*string{aws.String(instanceId)},
|
|
||||||
})
|
|
||||||
if err != nil || len(r.Reservations) == 0 || len(r.Reservations[0].Instances) == 0 {
|
if err != nil || len(r.Reservations) == 0 || len(r.Reservations[0].Instances) == 0 {
|
||||||
err := fmt.Errorf("Error finding source instance.")
|
err := fmt.Errorf("Error finding source instance.")
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
|
|
|
@ -231,10 +231,10 @@ func (s *StepRunSpotInstance) Run(state multistep.StateBag) multistep.StepAction
|
||||||
|
|
||||||
ui.Message(fmt.Sprintf("Instance ID: %s", instanceId))
|
ui.Message(fmt.Sprintf("Instance ID: %s", instanceId))
|
||||||
ui.Say(fmt.Sprintf("Waiting for instance (%v) to become ready...", instanceId))
|
ui.Say(fmt.Sprintf("Waiting for instance (%v) to become ready...", instanceId))
|
||||||
describeInstanceStatus := &ec2.DescribeInstanceStatusInput{
|
describeInstance := &ec2.DescribeInstancesInput{
|
||||||
InstanceIds: []*string{aws.String(instanceId)},
|
InstanceIds: []*string{aws.String(instanceId)},
|
||||||
}
|
}
|
||||||
if err := ec2conn.WaitUntilInstanceStatusOk(describeInstanceStatus); err != nil {
|
if err := ec2conn.WaitUntilInstanceRunning(describeInstance); err != nil {
|
||||||
err := fmt.Errorf("Error waiting for instance (%s) to become ready: %s", instanceId, err)
|
err := fmt.Errorf("Error waiting for instance (%s) to become ready: %s", instanceId, err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
ui.Error(err.Error())
|
ui.Error(err.Error())
|
||||||
|
|
|
@ -115,7 +115,6 @@ Packer to work:
|
||||||
"ec2:DeregisterImage",
|
"ec2:DeregisterImage",
|
||||||
"ec2:DescribeImageAttribute",
|
"ec2:DescribeImageAttribute",
|
||||||
"ec2:DescribeImages",
|
"ec2:DescribeImages",
|
||||||
"ec2:DescribeInstanceStatus",
|
|
||||||
"ec2:DescribeInstances",
|
"ec2:DescribeInstances",
|
||||||
"ec2:DescribeRegions",
|
"ec2:DescribeRegions",
|
||||||
"ec2:DescribeSecurityGroups",
|
"ec2:DescribeSecurityGroups",
|
||||||
|
|
Loading…
Reference in New Issue