Skip to content

Commit

Permalink
Merge pull request #13 from TomasMocek/master
Browse files Browse the repository at this point in the history
added "reserved_concurrent_executions" parameter
  • Loading branch information
mikael-lindstrom authored Apr 15, 2019
2 parents 5cb72ea + ab9d679 commit b9a8640
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 42 deletions.
88 changes: 46 additions & 42 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
# Resources
# ------------------------------------------------------------------------------
resource "aws_lambda_function" "main" {
count = "${var.attach_vpc_config == "false" && var.filename != "" ? 1 : 0}"
function_name = "${var.name_prefix}"
description = "Terraformed Lambda function."
filename = "${var.filename}"
handler = "${var.handler}"
source_code_hash = "${base64sha256(file(var.filename))}"
runtime = "${var.runtime}"
memory_size = "${var.memory_size}"
timeout = "${var.timeout}"
role = "${aws_iam_role.main.arn}"
count = "${var.attach_vpc_config == "false" && var.filename != "" ? 1 : 0}"
function_name = "${var.name_prefix}"
description = "Terraformed Lambda function."
filename = "${var.filename}"
handler = "${var.handler}"
source_code_hash = "${base64sha256(file(var.filename))}"
runtime = "${var.runtime}"
memory_size = "${var.memory_size}"
timeout = "${var.timeout}"
role = "${aws_iam_role.main.arn}"
reserved_concurrent_executions = "${var.reserved_concurrent_executions}"

environment {
variables = "${var.environment}"
Expand All @@ -21,16 +22,17 @@ resource "aws_lambda_function" "main" {
}

resource "aws_lambda_function" "vpc" {
count = "${var.attach_vpc_config == "true" && var.filename != "" ? 1 : 0}"
function_name = "${var.name_prefix}"
description = "Terraformed Lambda function."
filename = "${var.filename}"
handler = "${var.handler}"
source_code_hash = "${base64sha256(file(var.filename))}"
runtime = "${var.runtime}"
memory_size = "${var.memory_size}"
timeout = "${var.timeout}"
role = "${aws_iam_role.main.arn}"
count = "${var.attach_vpc_config == "true" && var.filename != "" ? 1 : 0}"
function_name = "${var.name_prefix}"
description = "Terraformed Lambda function."
filename = "${var.filename}"
handler = "${var.handler}"
source_code_hash = "${base64sha256(file(var.filename))}"
runtime = "${var.runtime}"
memory_size = "${var.memory_size}"
timeout = "${var.timeout}"
role = "${aws_iam_role.main.arn}"
reserved_concurrent_executions = "${var.reserved_concurrent_executions}"

vpc_config {
subnet_ids = ["${var.subnet_ids}"]
Expand All @@ -45,17 +47,18 @@ resource "aws_lambda_function" "vpc" {
}

resource "aws_lambda_function" "main_s3" {
count = "${var.attach_vpc_config == "false" && var.filename == "" ? 1 : 0}"
function_name = "${var.name_prefix}"
description = "Terraformed Lambda function."
s3_bucket = "${var.s3_bucket}"
s3_key = "${var.s3_key}"
s3_object_version = "${var.s3_trigger_updates == true ? data.aws_s3_bucket_object.main.version_id : "" }"
handler = "${var.handler}"
runtime = "${var.runtime}"
memory_size = "${var.memory_size}"
timeout = "${var.timeout}"
role = "${aws_iam_role.main.arn}"
count = "${var.attach_vpc_config == "false" && var.filename == "" ? 1 : 0}"
function_name = "${var.name_prefix}"
description = "Terraformed Lambda function."
s3_bucket = "${var.s3_bucket}"
s3_key = "${var.s3_key}"
s3_object_version = "${var.s3_trigger_updates == true ? data.aws_s3_bucket_object.main.version_id : "" }"
handler = "${var.handler}"
runtime = "${var.runtime}"
memory_size = "${var.memory_size}"
timeout = "${var.timeout}"
role = "${aws_iam_role.main.arn}"
reserved_concurrent_executions = "${var.reserved_concurrent_executions}"

environment {
variables = "${var.environment}"
Expand All @@ -70,17 +73,18 @@ data "aws_s3_bucket_object" "main" {
}

resource "aws_lambda_function" "vpc_s3" {
count = "${var.attach_vpc_config == "true" && var.filename == "" ? 1 : 0}"
function_name = "${var.name_prefix}"
description = "Terraformed Lambda function."
s3_bucket = "${var.s3_bucket}"
s3_key = "${var.s3_key}"
s3_object_version = "${var.s3_trigger_updates == true ? data.aws_s3_bucket_object.main.version_id : "" }"
handler = "${var.handler}"
runtime = "${var.runtime}"
memory_size = "${var.memory_size}"
timeout = "${var.timeout}"
role = "${aws_iam_role.main.arn}"
count = "${var.attach_vpc_config == "true" && var.filename == "" ? 1 : 0}"
function_name = "${var.name_prefix}"
description = "Terraformed Lambda function."
s3_bucket = "${var.s3_bucket}"
s3_key = "${var.s3_key}"
s3_object_version = "${var.s3_trigger_updates == true ? data.aws_s3_bucket_object.main.version_id : "" }"
handler = "${var.handler}"
runtime = "${var.runtime}"
memory_size = "${var.memory_size}"
timeout = "${var.timeout}"
role = "${aws_iam_role.main.arn}"
reserved_concurrent_executions = "${var.reserved_concurrent_executions}"

vpc_config {
subnet_ids = ["${var.subnet_ids}"]
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,8 @@ variable "s3_key" {
description = "The s3 key for the Lambda artifact."
default = ""
}

variable "reserved_concurrent_executions" {
description = "The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1"
default = -1
}

0 comments on commit b9a8640

Please sign in to comment.