terraform-aws-lambda icon indicating copy to clipboard operation
terraform-aws-lambda copied to clipboard

Extra quotes added from python packager

Open busla opened this issue 3 years ago β€’ 0 comments

Description

  • [x] βœ‹ I have searched the open/closed issues and my issue is not listed.

Related https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/215

Versions

  • Module version: 3.3.1

  • Terraform version: 1.2.6

  • Terragrunt version: 0.38.6

  • Provider version(s):


provider "registry.terraform.io/hashicorp/aws" {
  version     = "4.25.0"
  constraints = ">= 4.9.0"
}

provider "registry.terraform.io/hashicorp/external" {
  version     = "2.2.2"
  constraints = ">= 1.0.0"
}

provider "registry.terraform.io/hashicorp/local" {
  version     = "2.2.3"
  constraints = ">= 1.0.0"
}

provider "registry.terraform.io/hashicorp/null" {
  version     = "3.1.1"
  constraints = ">= 2.0.0"
}

Reproduction Code [Required]

Using terragrunt and the jsonencode fix mentioned here https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/215

When using multiple source paths, the python packaging script seems to add extra double quotes before and after the paths.

Broken 1

  ...
  source_path = [
    jsonencode("${get_repo_root()}/../some/path/to/module"),
    jsonencode("${get_repo_root()}/../some/path/to/module/subdir"),
    {
      pip_requirements =     ...
    }
  ]
β”‚ Could not locate source_path
β”‚ ""/repo/root/../some/path/to/module"".

Note the extra double quotes from the python parser.

Broken 2

locals {
  ...
  python_source_path = jsonencode("${get_repo_root()}/../some/path/to/module")
}

...
  source_path = [
    local.python_source_path,
    "${local.python_source_path}/subdir",
    {
      pip_requirements =     ...
    }
  ]
β”‚ Could not locate source_path
β”‚ ""/repo/root/../some/path/to/module"/subdir".

Workaround

  ...
  source_path = [
    replace(jsonencode("${get_repo_root()}/../some/path/to/module"), "\"", ""),
    replace(jsonencode("${get_repo_root()}/../some/path/to/module/subdir"), "\"", ""),
    {
      pip_requirements =     ...
    }
  ]

busla avatar Aug 10 '22 00:08 busla