Skip to content

Commit d3109cf

Browse files
authored
Support deloying lambda to VPC (#8)
1 parent 0317ceb commit d3109cf

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Module Input Variables
1414
- `schedule_expression` - a [valid rate or cron expression](http://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-schedule-expressions.html)
1515
- `iam_policy_document` - a valid IAM policy document used for the Lambda's [execution role](http://docs.aws.amazon.com/lambda/latest/dg/intro-permission-model.html#lambda-intro-execution-role)
1616
- `timeout` - (optional) the amount of time your Lambda Function has to run in seconds. Defaults to 3. See [Limits](https://docs.aws.amazon.com/lambda/latest/dg/limits.html)
17+
- `subnet_ids` (optional) - If set, the lambda will be deployed inside a VPC on the subnet(s) specified. Expects a comma separated list of valid AWS subnet ids.
18+
- `security_group_ids` (optional) - If set, the lambda will be deployed inside a VPC and use the security groups specified. Expects a comma separated list of valid VPC security group ids .
1719
- `enabled` - boolean expression. If false, the lambda function and the cloudwatch schedule are not set. Defaults to `true`.
1820

1921
Usage

main.tf

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ resource "aws_lambda_function" "lambda" {
3434
source_code_hash = "${var.source_code_hash}"
3535
count = "${var.enabled}"
3636
timeout = "${var.timeout}"
37+
38+
vpc_config {
39+
subnet_ids = ["${var.subnet_ids}"]
40+
security_group_ids = ["${var.security_group_ids}"]
41+
}
3742
}
3843

3944
resource "aws_lambda_permission" "cloudwatch" {

variables.tf

+8
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ variable "enabled" {
1919
variable "timeout" {
2020
default = 3
2121
}
22+
23+
variable "subnet_ids" {
24+
default = []
25+
}
26+
27+
variable "security_group_ids" {
28+
default = []
29+
}

0 commit comments

Comments
 (0)