terraform-aws-modules / terraform-aws-lambda

Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/lambda/aws
Apache License 2.0
886 stars 657 forks source link

Errors when integrating with API GW #405

Closed royassis closed 1 year ago

royassis commented 1 year ago

Description

This Terraform project contains terraform-aws-modules/lambda/aws modules and resources of a Private Rest API Gateway. After applying using Terraform Cloud, the API-GW endpoints return:

{
  "message": "Internal server error"
}

This happens only when I change the code in the source_path of the module. And it affects only the current deployment of the apigw stage. When running the lambda from the test console of API Gateway it works, so does testing the lambda from the lambda console. Creating a new deployment fixes it. When looking at the previous lambda version the Resource-based policy statements looks ok.

⚠️ Note

Before you submit an issue, please perform the following first:

  1. Remove the local .terraform directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!): rm -rf .terraform/
  2. Re-initialize the project root to pull down modules: terraform init
  3. Re-attempt your terraform plan or apply and check if the issue still persists

Versions

Your version of Terraform is out of date! The latest version is 1.3.7. You can update by downloading from https://www.terraform.io/downloads.html

Reproduction Code [Required]

Steps to reproduce the behavior:

```terraform locals { source_arn = "arn:aws:execute-api:::/*/*/*" } locals { allowed_triggers = { APIGatewayAny = { service = "apigateway" source_arn = local.source_arn } } } module "lambda_function_GetApigwResources" { source = "terraform-aws-modules/lambda/aws" function_name = "GetApigwResources" handler = "app.handler" runtime = "python3.9" timeout = 10 store_on_s3 = true s3_bucket = s3_prefix = "lambda-builds/" attach_policy_statements = true policy_statements = { apigateway = { effect = "Allow", actions = ["apigateway:Get*"], resources = ["*"] } } role_path = "/tf-managed/" policy_path = "/tf-managed/" source_path = "../src/lambda_code/describe_apigw_resources/app.py" tags = { "map-migrated" = var.map-migrated } # create_current_version_allowed_triggers = true publish = true allowed_triggers = local.allowed_triggers } ``` ## Expected behavior API GW returns a valid response. ## Actual behavior API GW return s ```json { "message": "Internal server error" } ``` ### Terminal Output Screenshot(s) ## Additional context
antonbabenko commented 1 year ago

The error is not related to the module itself. Please check logs in CloudWatch or in the Lambda console.

github-actions[bot] commented 1 year ago

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.