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

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

Closed
1 task done
MerreM opened this issue Mar 6, 2023 · 16 comments · Fixed by #194
Labels

Comments

@MerreM
Copy link

MerreM commented Mar 6, 2023

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
@MerreM MerreM added the bug label Mar 6, 2023
@SBGoods
Copy link
Contributor

SBGoods commented Mar 6, 2023

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

@MerreM
Copy link
Author

MerreM commented Mar 6, 2023

Thanks!

@pdecat
Copy link
Contributor

pdecat commented Mar 6, 2023

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.

@MerreM
Copy link
Author

MerreM commented Mar 6, 2023

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

@pdecat
Copy link
Contributor

pdecat commented Mar 6, 2023

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.

@MerreM
Copy link
Author

MerreM commented Mar 6, 2023

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

@pdecat
Copy link
Contributor

pdecat commented Mar 6, 2023

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

@SBGoods
Copy link
Contributor

SBGoods commented Mar 6, 2023

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!

@pneigel-ca
Copy link

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!

@plukevdh
Copy link

plukevdh commented Mar 6, 2023

2.3.1 resolves for us as well. Thanks!

@lorengordon
Copy link

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!

@MerreM
Copy link
Author

MerreM commented Mar 7, 2023

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!

@lorengordon
Copy link

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

@bflad
Copy link
Member

bflad commented Apr 6, 2023

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

@lorengordon
Copy link

@bflad Done, #208

Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants