|
|
|
|
@ -11,6 +11,7 @@ import (
|
|
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
|
|
|
|
"github.com/aws/aws-sdk-go/service/ec2"
|
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/packer/builder/amazon/common/awserrors"
|
|
|
|
|
"github.com/hashicorp/packer/common/retry"
|
|
|
|
|
"github.com/hashicorp/packer/helper/communicator"
|
|
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
|
|
|
|
@ -204,7 +205,7 @@ func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBa
|
|
|
|
|
err = retry.Config{
|
|
|
|
|
Tries: 11,
|
|
|
|
|
ShouldRetry: func(err error) bool {
|
|
|
|
|
if IsAWSErr(err, "InvalidParameterValue", "iamInstanceProfile") {
|
|
|
|
|
if awserrors.Matches(err, "InvalidParameterValue", "iamInstanceProfile") {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
@ -215,7 +216,7 @@ func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBa
|
|
|
|
|
return err
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if IsAWSErr(err, "VPCIdNotSpecified", "No default VPC for this user") && subnetId == "" {
|
|
|
|
|
if awserrors.Matches(err, "VPCIdNotSpecified", "No default VPC for this user") && subnetId == "" {
|
|
|
|
|
err := fmt.Errorf("Error launching source instance: a valid Subnet Id was not specified")
|
|
|
|
|
state.Put("error", err)
|
|
|
|
|
ui.Error(err.Error())
|
|
|
|
|
@ -253,7 +254,7 @@ func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBa
|
|
|
|
|
|
|
|
|
|
var r *ec2.DescribeInstancesOutput
|
|
|
|
|
err = retry.Config{Tries: 11, ShouldRetry: func(err error) bool {
|
|
|
|
|
if IsAWSErr(err, "InvalidInstanceID.NotFound", "") {
|
|
|
|
|
if awserrors.Matches(err, "InvalidInstanceID.NotFound", "") {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
@ -298,7 +299,7 @@ func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBa
|
|
|
|
|
ec2Tags.Report(ui)
|
|
|
|
|
// Retry creating tags for about 2.5 minutes
|
|
|
|
|
err = retry.Config{Tries: 11, ShouldRetry: func(error) bool {
|
|
|
|
|
if IsAWSErr(err, "InvalidInstanceID.NotFound", "") {
|
|
|
|
|
if awserrors.Matches(err, "InvalidInstanceID.NotFound", "") {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
|