Skip to content

Commit 18b8620

Browse files
natemccurdymilldr
andauthored
fix: Add null/label context tags to the aws_lambda_function resource (#44)
Problem: Prior to this, the `aws_lambda_function` resource was not getting tagged at all when passing just the null/label context into the module. For example, this would end up with a completely untagged Lambda function even though I am passing the context from a standard null/label declaration: ``` module "test" { source = "cloudposse/lambda-function/aws" version = "0.5.1" function_name = "${module.this.id}-test" attributes = ["foo"] description = var.lambda_description s3_bucket = var.lambda_s3_bucket s3_key = var.lambda_s3_key runtime = var.lambda_runtime handler = var.lambda_handler context = module.this.context } ``` To get any tags on the lambda, the `tags` attribute must be used: ``` module "test" { source = "cloudposse/lambda-function/aws" version = "0.5.1" function_name = "${module.this.id}-test" attributes = ["foo"] description = var.lambda_description s3_bucket = var.lambda_s3_bucket s3_key = var.lambda_s3_key runtime = var.lambda_runtime handler = var.lambda_handler context = module.this.context tags = module.this.tags } ``` The requirement of passing an explicit `tags` attribute is not how other CloudPosse modules work. In most other CloudPosse modules, you can just pass around a null/label context and the tags will automatically show up in child resources. Solution: Use `tags = module.this.tags` on the `aws_lambda_function` resource. Outcome: * The `aws_lambda_function` resource is tagged with the implicit tags passed in via `context`. * Tags from the `tags` variable are still present, but are now merged with the tags from `context`. * This module follows the convetion of other CloudPosse modules. * People used to CloudPosse modules will have an easier time using this module. Co-authored-by: Dan Miller <[email protected]>
1 parent 517135d commit 18b8620

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ resource "aws_lambda_function" "this" {
3939
s3_key = var.s3_key
4040
s3_object_version = var.s3_object_version
4141
source_code_hash = var.source_code_hash
42-
tags = var.tags
42+
tags = module.this.tags
4343
timeout = var.timeout
4444

4545
dynamic "dead_letter_config" {

0 commit comments

Comments
 (0)