hashicorp/terraform-provider-external

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

MerreM opened this issue · 16 comments

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

Hi @MerreM, sorry that you are running into this issue. I'm taking a look into this now.

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).

Edit: given the fix in the related PR, it isn't caused by the switch to the plugin framework.

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

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.

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"
    }
  }

Nope, adding the version constraints is done with something like this which is usually put into a versions.tf file:

terraform {
  required_providers {
    external = {
      version = "< 2.3.0" # https://github.com/hashicorp/terraform-provider-external/issues/193
    }
  }
}

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!

2.3.1 resolves for us as well. Thanks!

Wow that was nearly a full day of frustration, eventually just solved by another terraform init! Can also confirm 2.3.1 fixes this problem. Thanks for the quick release!

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.

Good chance I made a mistake with my pipelines there - I expect your fix would have worked had I managed to call it via CI.

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!

Thank you for the quick fix!

This is actually still failing as a behavioral change, because it converts null to "" instead of simply passing nothing.

bflad commented

@lorengordon can you please raise a new issue? Thank you.

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.