Skip to content
Permalink
Browse files

fix nil reference when vpc is not configured

due to previous commit
  • Loading branch information...
tj committed Jul 22, 2018
1 parent f1bee26 commit e8b59047fcee71e6111ef852ab39f8ebd990f2a5
Showing with 15 additions and 8 deletions.
  1. +15 −8 platform/lambda/lambda.go
@@ -561,10 +561,7 @@ retry:
S3Bucket: b,
S3Key: k,
},
VpcConfig: &lambda.VpcConfig{
SubnetIds: aws.StringSlice(p.config.Lambda.VPC.Subnets),
SecurityGroupIds: aws.StringSlice(p.config.Lambda.VPC.SecurityGroups),
},
VpcConfig: p.vpc(),
})

// IAM is eventually consistent apparently, so we have to keep retrying
@@ -622,10 +619,7 @@ func (p *Platform) updateFunction(c *lambda.Lambda, a *apigateway.APIGateway, up
MemorySize: aws.Int64(int64(p.config.Lambda.Memory)),
Timeout: aws.Int64(int64(p.config.Proxy.Timeout + 3)),
Environment: env,
VpcConfig: &lambda.VpcConfig{
SubnetIds: aws.StringSlice(p.config.Lambda.VPC.Subnets),
SecurityGroupIds: aws.StringSlice(p.config.Lambda.VPC.SecurityGroups),
},
VpcConfig: p.vpc(),
})

if err != nil {
@@ -660,6 +654,19 @@ func (p *Platform) updateFunction(c *lambda.Lambda, a *apigateway.APIGateway, up
return *res.Version, nil
}

// vpc returns the vpc configuration or nil.
func (p *Platform) vpc() *lambda.VpcConfig {
v := p.config.Lambda.VPC
if v == nil {
return nil
}

return &lambda.VpcConfig{
SubnetIds: aws.StringSlice(v.Subnets),
SecurityGroupIds: aws.StringSlice(v.SecurityGroups),
}
}

// 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)

0 comments on commit e8b5904

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