Skip to content

Commit e8b5904

Browse files
committed
fix nil reference when vpc is not configured
due to previous commit
1 parent f1bee26 commit e8b5904

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

platform/lambda/lambda.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,7 @@ retry:
561561
S3Bucket: b,
562562
S3Key: k,
563563
},
564-
VpcConfig: &lambda.VpcConfig{
565-
SubnetIds: aws.StringSlice(p.config.Lambda.VPC.Subnets),
566-
SecurityGroupIds: aws.StringSlice(p.config.Lambda.VPC.SecurityGroups),
567-
},
564+
VpcConfig: p.vpc(),
568565
})
569566

570567
// 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
622619
MemorySize: aws.Int64(int64(p.config.Lambda.Memory)),
623620
Timeout: aws.Int64(int64(p.config.Proxy.Timeout + 3)),
624621
Environment: env,
625-
VpcConfig: &lambda.VpcConfig{
626-
SubnetIds: aws.StringSlice(p.config.Lambda.VPC.Subnets),
627-
SecurityGroupIds: aws.StringSlice(p.config.Lambda.VPC.SecurityGroups),
628-
},
622+
VpcConfig: p.vpc(),
629623
})
630624

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

657+
// vpc returns the vpc configuration or nil.
658+
func (p *Platform) vpc() *lambda.VpcConfig {
659+
v := p.config.Lambda.VPC
660+
if v == nil {
661+
return nil
662+
}
663+
664+
return &lambda.VpcConfig{
665+
SubnetIds: aws.StringSlice(v.Subnets),
666+
SecurityGroupIds: aws.StringSlice(v.SecurityGroups),
667+
}
668+
}
669+
663670
// alias creates or updates an alias.
664671
func (p *Platform) alias(c *lambda.Lambda, alias, version string) error {
665672
log.Debugf("alias %s to %s", alias, version)

0 commit comments

Comments
 (0)