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

Error: in data "archive_file" "zip_file_for_lambda"

Open salvadorcoronel opened this issue 4 years ago • 2 comments

terraform -version

Terraform v1.0.11 on darwin_amd64

  • provider registry.terraform.io/hashicorp/archive v2.2.0
  • provider registry.terraform.io/hashicorp/aws v3.66.0

I get this error when run this command: terraform init terraform apply

Error: with module.redirect_externalurl_lambda.data.archive_file.zip_file_for_lambda, │ on .terraform/modules/redirect_externalurl_lambda/main.tf line 9, in data "archive_file" "zip_file_for_lambda": │ 9: data "archive_file" "zip_file_for_lambda" {

This is my main.tf file

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.65"
    }
  }

  required_version = ">= 0.14.9"
}

provider "aws" {
  profile = "default"
  region  = "us-east-1"
}

module "abcdef_lambda_edge_module" {
  source                 = "transcend-io/lambda-at-edge/aws"
  version                = "0.4.0"
  name                   = "abcdef_lambda_edge"
  description            = "Some description..."
  runtime                = "nodejs14.x"
  lambda_code_source_dir = "${path.module}"
  s3_artifact_bucket     = "abcdef.lambda.deploy"
}

salvadorcoronel avatar Nov 23 '21 22:11 salvadorcoronel

Same here. Unfortunately, the last commit was about half a year ago, so I don't think there will be immediate help.

Check out this blog post to build lambda@edge yourself, from the same authors as this module here: https://transcend.io/blog/lambda-edge-functions-in-terraform

patryk-eco avatar Jan 10 '22 14:01 patryk-eco

I also encountered this, but this was du to a misunderstanding how the variable lambda_code_source_dir works, or actually that there needs to be a certain structure.

If you check out variables.tf variable file_globs you might see what I mean.<br > The module basically zips all files in lambda_code_source_dir that match the entries in file_globs. So you either rename your files accordingly or extend the file_globs in the module definition.

However, I'm not sure this module is actively cared for. There is a pull request pending for a while concerning the default runtime and deprecation warnings about the S3 resources are popping up.

i-r-raccoon avatar Feb 23 '22 11:02 i-r-raccoon