Skip to content
Permalink
Browse files

add vpc support. Closes #281

my bad, could have added this a long time ago,
my default VPC routing was messed so I thought we needed
some extra work to get APIGW -> Lambda working properly
  • Loading branch information...
tj committed May 18, 2018
1 parent 419236d commit bbf4071acb18b4bca1d17769c53f6befa52d9801
Showing with 29 additions and 1 deletion.
  1. +9 −0 config/lambda.go
  2. +12 −1 docs/04-configuration.md
  3. +8 −0 platform/lambda/lambda.go
@@ -22,6 +22,12 @@ var defaultPolicy = IAMPolicyStatement{
// IAMPolicyStatement configuration.
type IAMPolicyStatement map[string]interface{}

// VPC configuration.
type VPC struct {
Subnets []string `json:"subnets"`
SecurityGroups []string `json:"security_groups"`
}

// Lambda configuration.
type Lambda struct {
// Memory of the function.
@@ -38,6 +44,9 @@ type Lambda struct {

// Policy of the function role.
Policy []IAMPolicyStatement `json:"policy"`

// VPC configuration.
VPC VPC `json:"vpc"`
}

// Default implementation.
@@ -96,6 +96,7 @@ The following Lambda-specific settings are available:
- `memory` – Function memory in mb (Default `512`, Min `128`, Max `1536`)
- `runtime` – Function runtime (Default `nodejs8.10`)
- `policy` – IAM function policy statement(s)
- `vpc` - VPC subnets and security groups

For example:

@@ -104,7 +105,17 @@ For example:
"name": "api",
"lambda": {
"memory": 512,
"runtime": "nodejs6.10"
"runtime": "nodejs6.10",
"vpc": {
"subnets": [
"subnet-aaaaaaa",
"subnet-bbbbbbb",
"subnet-ccccccc",
],
"security_groups": [
"sg-xxxxxxx"
]
}
}
}
```
@@ -561,6 +561,10 @@ retry:
S3Bucket: b,
S3Key: k,
},
VpcConfig: &lambda.VpcConfig{
SubnetIds: aws.StringSlice(p.config.Lambda.VPC.Subnets),
SecurityGroupIds: aws.StringSlice(p.config.Lambda.VPC.SecurityGroups),
},
})

// IAM is eventually consistent apparently, so we have to keep retrying
@@ -618,6 +622,10 @@ 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),
},
})

if err != nil {

0 comments on commit bbf4071

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