Skip to content

Commit

Permalink
create alias if alias is not exists on deploy.
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwara committed Oct 29, 2019
1 parent 7c87784 commit 9a7e87b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,20 @@ func (app *App) updateAliases(functionName string, vs ...versionAlias) error {
Name: aws.String(v.Name),
})
if err != nil {
return errors.Wrapf(err, "failed to update alias")
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case lambda.ErrCodeResourceNotFoundException:
log.Printf("[info] alias %s is not found. creating alias", v.Name)
alias, err = app.lambda.CreateAlias(&lambda.CreateAliasInput{
FunctionName: aws.String(functionName),
FunctionVersion: aws.String(v.Version),
Name: aws.String(v.Name),
})
}
}
if err != nil {
return errors.Wrap(err, "failed to update alias")
}
}
log.Println("[info] alias updated")
log.Printf("[debug]\n%s", alias.String())
Expand Down

0 comments on commit 9a7e87b

Please sign in to comment.