Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Oct 11, 2023
Merged

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

merged 2 commits into from
Oct 11, 2023

Commits on Oct 11, 2023

  1. fix: Add null/label context tags to the aws_lambda_function resource

    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.
    natemccurdy committed Oct 11, 2023
    Configuration menu
    Copy the full SHA
    117f786 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    47b3cf9 View commit details
    Browse the repository at this point in the history