terraform-provider-external: External version 2.3.0 appears to break python packaging in https://github.com/terraform-aws-modules/terraform-aws-lambda

Terraform CLI and Provider Versions

terraform 1.3.7 https://github.com/terraform-aws-modules/terraform-aws-lambda 4.10.1 & 4.7.1

Terraform Configuration

module "lambda" {
  source  = "terraform-aws-modules/lambda/aws"
  version = "v4.10.1"

  attach_policy_statements          = true
  cloudwatch_logs_retention_in_days = var.log_retention_in_days
  create_function                   = true
  function_name                     = "${var.name}-session-update-handler"
  handler                           = "main.lambda_handler"
  publish                           = true
  runtime                           = "python3.9"
  source_path                       = "${path.module}/src/main.py"
  tags                              = var.tags
  hash_extra                        = ""

  environment_variables = {
    "table_name" : var.connection_table_name
    "domain" : var.api_ws_domain
    "stage" : var.api_ws_stage
  }


-- snip --

Expected Behavior

Terraform module would run package.py - and produce a zip file for upload

Actual Behavior

– snip –

websocket-lambda.ws-auth.lambda-function/package.py", line 1438, in prepare_command
│     content_hash.update(hash_extra.encode())
│ AttributeError: 'NoneType' object has no attribute 'encode'

Steps to Reproduce

  1. terraform apply

How much impact is this issue causing?

High

Logs

No response

Additional Information

Pipelines failed after external provider changed from 2.2.3 to 2.3.0 AFAIK no other changes have occurred.

Code of Conduct

  • I agree to follow this project’s Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 4
  • Comments: 15 (3 by maintainers)

Most upvoted comments

Hi @MerreM and @pdecat, we’ve just released v2.3.1 of the External provider which should resolve this issue. Please let us know if there are any other questions or concerns.

Thanks!

I can confirm the issue we are facing using the same module for lambda is resolved with no changes besides the provider update. Thank you!

FWIW hash_extra = “foo” doesn’t appear to work

Weird, it did for me. Anyway, I preferred to add a provider version constraint to avoid the problematic release.

Might have implemented it incorrectly.

To confirm (for both me and anyone that finds this) - the below should work?

module "lambda" {
  source  = "terraform-aws-modules/lambda/aws"
  version = "v4.10.1"
  providers = {
    external = {
      source  = "hashicorp/external"
      version = "2.2.3"
    }
  }

2.3.1 resolves for us as well. Thanks!

Sounds like empty string values passed in the query are now null instead of the empty string "" using the terraform-plugin-framework.

As a work-around, pass hash_extra = "foo" to the terraform-aws-modules/lambda/aws module (or downgrade the provider to v2.2.3).

FWIW hash_extra = “foo” doesn’t appear to work