Skip to content

Commit

Permalink
delete.go switch to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwara committed Jul 7, 2023
1 parent c51e777 commit a0bf800
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions delete.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package lambroll

import (
"context"
"fmt"
"log"

"github.com/aws/aws-sdk-go/service/lambda"
"github.com/pkg/errors"
lambdav2 "github.com/aws/aws-sdk-go-v2/service/lambda"
)

// DeleteOption represents options for Delete()
Expand All @@ -22,21 +23,22 @@ func (opt DeleteOption) label() string {

// Delete deletes function
func (app *App) Delete(opt DeleteOption) error {
ctx := context.TODO()
fn, err := app.loadFunction(*opt.FunctionFilePath)
if err != nil {
return errors.Wrap(err, "failed to load function")
return fmt.Errorf("failed to load function: %w", err)
}

log.Println("[info] deleting function", *fn.FunctionName, opt.label())

if *opt.DryRun {
return nil
}
_, err = app.lambda.DeleteFunction(&lambda.DeleteFunctionInput{
_, err = app.lambdav2.DeleteFunction(ctx, &lambdav2.DeleteFunctionInput{
FunctionName: fn.FunctionName,
})
if err != nil {
return errors.Wrap(err, "failed to delete function")
return fmt.Errorf("failed to delete function: %w", err)
}

return nil
Expand Down

0 comments on commit a0bf800

Please sign in to comment.