Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Wait until the function code has been successfully updated #314

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,11 @@ func (app *App) updateFunctionCode(ctx context.Context, in *lambda.UpdateFunctio
return nil, err
}

var res *lambda.FunctionConfiguration
retrier := retryPolicy.Start(ctx)
for retrier.Continue() {
res, err := app.lambda.UpdateFunctionCodeWithContext(ctx, in)
var err error
res, err = app.lambda.UpdateFunctionCodeWithContext(ctx, in)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
Expand All @@ -226,10 +228,20 @@ func (app *App) updateFunctionCode(ctx context.Context, in *lambda.UpdateFunctio
}
return nil, errors.Wrap(err, "failed to update function code")
}
log.Println("[info] updated function code successfully")
return res, nil
log.Println("[info] update function code request was accepted")
break
}
return nil, errors.New("failed to update function code (max retries reached)")

if !retrier.Continue() {
return nil, errors.New("failed to update function code (max retries reached)")
}

if err := app.waitForLastUpdateStatusSuccessful(ctx, *in.FunctionName); err != nil {
return nil, err
}
log.Println("[info] updated function code successfully")

return res, nil
}

func (app *App) waitForLastUpdateStatusSuccessful(ctx context.Context, name string) error {
Expand Down
Loading