cloudposse / terraform-aws-lambda-function

A module for launching Lambda Fuctions
https://cloudposse.com/accelerate
Apache License 2.0
30 stars 40 forks source link

fix: Add null/label context tags to the aws_lambda_function resource #44

Closed natemccurdy closed 11 months ago

natemccurdy commented 11 months ago

What

Use tags = module.this.tags on the aws_lambda_function resource.

Why

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
}

This has a couple of problems: 1) The attributes list is missing from the resultant set of tags. 2) The requirement of passing an explicit tags attribute is not how other CloudPosse modules work.

Outcome

Gowiem commented 11 months ago

/terratest

Gowiem commented 11 months ago

/terratest

milldr commented 11 months ago

/terratest

milldr commented 11 months ago

/terratest

natemccurdy commented 11 months ago

Thanks @milldr 🍻