Skip to content

Commit

Permalink
Merge pull request #3 from grzegorz-faryna-mergermarket/WM-2496
Browse files Browse the repository at this point in the history
WM-2496 - Added tags.
  • Loading branch information
keirbadger authored Aug 8, 2019
2 parents cc1975c + c4f1738 commit abf7d6d
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This module will deploy a Lambda function.
- `subnet_ids` - (string) - **REQUIRED** The VPC subnets in which the Lambda runs.
- `timeout` (number) - The maximum time in seconds that the Lambda can run for
- `reserved_concurrent_executions` (number) - The amount of reserved concurrent executions for this lambda function.
- `tags` (map) - A mapping of tags to assign to this lambda function.


## Usage
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ resource "aws_lambda_function" "lambda_function" {
timeout = "${var.timeout}"
memory_size = "${var.memory_size}"
reserved_concurrent_executions = "${var.reserved_concurrent_executions}"
tags = "${var.tags}"

vpc_config {
subnet_ids = "${var.subnet_ids}"
Expand Down
7 changes: 7 additions & 0 deletions test/infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module "lambda" {
subnet_ids = "${var.subnet_ids}"
security_group_ids = "${var.security_group_ids}"
reserved_concurrent_executions = "${var.reserved_concurrent_executions}"
tags = "${var.tags}"
}

variable "subnet_ids" {
Expand All @@ -47,6 +48,12 @@ variable "reserved_concurrent_executions" {
default = -1
}

variable "tags" {
description = "A mapping of tags to assign to this lambda function."
type = "map"
default = {}
}

output "lambda_function_arn" {
value = "${module.lambda.lambda_arn}"
}
37 changes: 37 additions & 0 deletions test/test_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,40 @@ def test_lambda_with_reserved_concurrent_executions(self):
vpc_config.0.vpc_id: <computed>
""").strip() in output

def test_lambda_with_tags(self):
output = check_output([
'terraform',
'plan',
'-var', 'tags={"component"="test-component" "env"="test"}',
'-no-color',
'test/infra'
]).decode('utf-8')
assert dedent("""
+ module.lambda.aws_lambda_function.lambda_function
id: <computed>
arn: <computed>
environment.#: "1"
function_name: "check_lambda_function"
handler: "some_handler"
invoke_arn: <computed>
last_modified: <computed>
memory_size: "128"
publish: "false"
qualified_arn: <computed>
reserved_concurrent_executions: "-1"
role: "${aws_iam_role.iam_for_lambda.arn}"
runtime: "python3.7"
s3_bucket: "cdflow-lambda-releases"
s3_key: "s3key.zip"
source_code_hash: <computed>
source_code_size: <computed>
tags.%: "2"
tags.component: "test-component"
tags.env: "test"
timeout: "3"
tracing_config.#: <computed>
version: <computed>
vpc_config.#: "1"
vpc_config.0.vpc_id: <computed>
""").strip() in output

6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,9 @@ variable "reserved_concurrent_executions" {
description = "Reserved concurrent executions for this Lambda"
default = -1
}

variable "tags" {
description = "A mapping of tags to assign to this lambda function."
type = "map"
default = {}
}

0 comments on commit abf7d6d

Please sign in to comment.