change retry func to a 15 min timeout

This commit is contained in:
Megan Marsh 2020-07-21 15:55:39 -07:00
parent a56942d3c7
commit 1f3b3f8fd9
1 changed files with 6 additions and 2 deletions

View File

@ -53,8 +53,12 @@ func (s *stepCreateAMI) Run(ctx context.Context, state multistep.StateBag) multi
var createResp *ec2.CreateImageOutput
var err error
// Create a timeout for the CreateImage call.
timeoutCtx, cancel := context.WithTimeout(ctx, time.Minute*15)
defer cancel()
err = retry.Config{
Tries: 11,
Tries: 0,
ShouldRetry: func(err error) bool {
if awscommon.IsAWSErr(err, "InvalidParameterValue", "Instance is not in state") {
return true
@ -62,7 +66,7 @@ func (s *stepCreateAMI) Run(ctx context.Context, state multistep.StateBag) multi
return false
},
RetryDelay: (&retry.Backoff{InitialBackoff: 200 * time.Millisecond, MaxBackoff: 30 * time.Second, Multiplier: 2}).Linear,
}.Run(ctx, func(ctx context.Context) error {
}.Run(timeoutCtx, func(ctx context.Context) error {
createResp, err = ec2conn.CreateImage(createOpts)
return err
})