diff --git a/README.md b/README.md index 0cb8ec0..a233ef2 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,5 @@ module "lambda" { } source_dir = "lambda/src" - - tags = { - app = "example" - env = "production" - } } ``` diff --git a/_test/main.tf b/_test/main.tf index 31415e7..73f592f 100644 --- a/_test/main.tf +++ b/_test/main.tf @@ -3,7 +3,7 @@ provider "aws" { } module "lambda" { - source = "./.." + source = "./.." function_name = "example" description = "This is an example" @@ -20,7 +20,7 @@ module "lambda" { source_dir = "lambda/src" - tags = { + default_tags = { app = "example" env = "production" } diff --git a/main.tf b/main.tf index ee24a6c..c30fb7f 100644 --- a/main.tf +++ b/main.tf @@ -34,7 +34,7 @@ resource "aws_lambda_function" "this" { filename = try(var.archive_file.output_path, data.archive_file.this[0].output_path) source_code_hash = try(var.archive_file.output_base64sha256, data.archive_file.this[0].output_base64sha256) - tags = var.tags + tags = merge(var.default_tags, var.lambda_function_tags) depends_on = [ aws_cloudwatch_log_group.this, @@ -57,7 +57,7 @@ resource "aws_iam_role" "this" { assume_role_policy = data.aws_iam_policy_document.lambda-assume-role.json - tags = var.tags + tags = merge(var.default_tags, var.iam_role_tags) } data "aws_iam_policy_document" "lambda-assume-role" { @@ -84,7 +84,7 @@ resource "aws_cloudwatch_log_group" "this" { retention_in_days = var.cloudwatch_log_group_retention_in_days - tags = var.tags + tags = merge(var.default_tags, var.cloudwatch_log_group_tags) } data "aws_iam_policy_document" "cloudwatch-log-group" { @@ -116,7 +116,7 @@ resource "aws_security_group" "this" { tags = merge({ Name = "Lambda: ${var.function_name}" - }, var.tags) + }, var.default_tags, var.security_group_tags) lifecycle { create_before_destroy = true diff --git a/variables.tf b/variables.tf index eca2c0f..409b8cf 100644 --- a/variables.tf +++ b/variables.tf @@ -5,64 +5,120 @@ variable "archive_file" { }) default = null - description = "An instance of the `archive_file` data source containing the code of the Lambda function. Conflicts with `source_dir`." + description = <