Skip to content
Permalink
Browse files

add alias upserts when updating

merged from pro
  • Loading branch information...
tj committed Mar 1, 2018
1 parent 76b3e25 commit 61e50f8f404e3e9e34073ad3a515d563e111ba22
Showing with 20 additions and 7 deletions.
  1. +20 −7 platform/lambda/lambda.go
@@ -612,18 +612,31 @@ retry:
return "", errors.Wrap(err, "updating function code")
}

log.Debugf("alias %s to %s", stage, *res.Version)
_, err = c.UpdateAlias(&lambda.UpdateAliasInput{
if err := p.alias(c, stage, *res.Version); err != nil {
return "", errors.Wrapf(err, "creating function %q alias", stage)
}

return *res.Version, nil
}

// alias creates or updates an alias.
func (p *Platform) alias(c *lambda.Lambda, alias, version string) error {
log.Debugf("alias %s to %s", alias, version)
_, err := c.UpdateAlias(&lambda.UpdateAliasInput{
FunctionName: &p.config.Name,
FunctionVersion: res.Version,
Name: &stage,
FunctionVersion: &version,
Name: &alias,
})

if err != nil {
return "", errors.Wrap(err, "updating function alias")
if util.IsNotFound(err) {
_, err = c.CreateAlias(&lambda.CreateAliasInput{
FunctionName: &p.config.Name,
FunctionVersion: &version,
Name: &alias,
})
}

return *res.Version, nil
return err
}

// deleteFunction deletes the lambda function.

0 comments on commit 61e50f8

Please sign in to comment.
You can’t perform that action at this time.